Mass warps the fabric of space, which results in curved spacetime, otherwise known as gravity wells or dents in space and time. The light follows a curved path thru the warped spacetime, which is the energy free path. Matter follows curved paths as well, which is why we remain in orbit about the sun. Per Einstein, gravitation is not really a force in the traditional sense. Instead, the dents in a non euclidean spacetime direct a body's motion, whereby curved paths become the inertial paths.
Light does not have rest mass, but it does have an effective mass and carries momentum.
Here's a link about the mass of light, and which suggests that light produces gravitation ...
http://math.ucr.edu/home/baez/physics/Relativity/SR/light_mass.html"
There are many links which discuss the bending of light. I'm having a little trouble finding a good one though.