There are two different ways of looking at it. One is that space is distorted around massive objects and that light is simply travelling on a distorted path around that object. Another is that light has its own gravitational field generated by its energy, which in turn is attracted to the gravitational field of other objects like stars. This attraction causes its path to deflect as it travels near an object.
The following users thanked this post: Zer0