Light is affected by gravity due to the curvature of spacetime, as described by general relativity, rather than through a direct attraction to mass. Photons, while massless, possess energy and momentum, which interact with the stress-energy tensor, allowing gravity to influence their path. As massive objects distort spacetime, light follows the geodesics created by this curvature, appearing to bend around these objects. This bending is not due to gravity attracting light but rather the result of light traveling through warped space. The phenomenon illustrates how gravity alters the geometry of space, affecting the trajectory of light without requiring mass.