Gravitational deflection of starlight around the Sun during the 1919 total solar eclipse provided measurements that confirmed Einstein’s general theory of relativity. We have used the Hubble Space Telescope to measure the analogous process of astrometric microlensing caused by a nearby star, the white dwarf Stein 2051 B. As Stein 2051 B passed closely in front of a background star, the background star’s position was deflected. Measurement of this deflection at multiple epochs allowed us to determine the mass of Stein 2051 B—the sixth-nearest white dwarf to the Sun—as 0.675 ± 0.051 solar masses. This mass determination provides confirmation of the physics of degenerate matter and lends support to white dwarf evolutionary theory.