Spiral galaxies are disks of stars and gas which rotate around their center due to the force of gravity holding them together. Without gravity, the disks would fly apart due to their large circular velocities. By measuring the speed at which the stars and gas move, we can calculate the amount of mass necessary to hold them on circular orbits, in essence measuring the mass of the galaxy.
To measure the rotation speed of a spiral galaxy, we take a spectrum of the galaxy and measure the doppler shift of the emission lines (hydrogen alpha in the optical, neutral hydrogen 21 cm in the radio). From these observations we can construct the observed line of sight velocity of different parts of the galaxy. In the simplest sense, we can tell a galaxy is rotating when one side of the galaxy is moving towards us and the other is moving away.
Figure 1 - NGC 2403, a nearby spiral galaxy.
Using the data we can construct a "rotation curve" of the galaxy -- a plot of rotational velocity as a function of radius in the galaxy. There is one complication in that galaxies are typically inclined to our line of sight so that we really measure
V × sin(i),but for normal spirals it is fairly straightforward to determine and correct for the inclination. Once that is done we can plot the rotation curve of the galaxy.
Figure 2 - Rotation curve for NGC 2403.
In principle, from this plot it is simple then to calculate the mass of the galaxy. If we assume the galaxy is spherical, we can then say that
V=(GM/r) ½ ,or solve for mass as M=rV ² /G. The fact that disk galaxies are not spherical means there is a small correction factor we need to apply, but the basic idea stays the same.
But when astronomers first tried to do that, they ran into an astonishing problem: rotation curves of spiral galaxies are flat.