Light rays from a source passing a mass are bent due to the gravity of the mass causing the observed image to change in both shape and size. This effect is called gravitational lensing and, among other applications, is used to infer the mass of the lens. This Demonstration displays the image created by a point mass lens. The original source is a disk at a fixed distance of light years from the observer.
The observed image depends on the mass of the lens, the distance between the observer and the lens, the size of the source, and the position of the source relative to the lens.
A light ray observed to be at an angle from the lens is deflected by the angle :
where is the gravitational constant and is the speed of light.
Gravitational lensing was first predicted by Albert Einstein's general theory of relativity and confirms that gravity changes the shape of spacetime, causing light rays to be bent. Strong lensing creates multiple images from a source. A lens that is axially symmetric will create an image of a ring, called the Einstein ring, when the source is directly behind the lens. The first observation of a lensing effect with the Sun as the lens was in 1919  and the first lensing event by a galaxy was observed in 1979 .
For further reading see:
 F. W. Dyson, A. S. Eddington, and C. Davidson, "A Determination of the Deflection of Light by the Sun's Gravitational Field, from Observations Made at the Total Eclipse of May 29, 1919," Philosophical Transactions of the Royal Society of London, 220, 1920 pp. 291–333.
 D. Walsh, R. F. Carswell, and R. J. Weymann, "0957 + 561 A, B—Twin Quasistellar Objects or Gravitational Lens," Nature, 279, 1979 pp. 381-384.