Does mAh measure how long a battery would last?
mAh (or mA&middot;h) is not how many milliamperes a battery can deliver in an hour. That would be mA/h. Current, measured in amperes, is already a rate of stuff. Specially, one ampere is one coulomb per second. So, if current is like speed, then mA/h is like acceleration, and mAh is like distance.

Rather, mAh it is a unit of charge. It is what you get when you multiply current by time. By multiplying by time, the "per time" part of the ampere is cancelled, and you get back to charge.

If an ampere is a coulomb per second, then:

$$ \require{cancel} 1~\mathrm{mAh} = 1\cdot10^{-3}~\mathrm{\frac{C}{s}h} $$

and by dimensional analysis:

$$ \require{cancel}
\frac{1\cdot10^{-3}~\mathrm{C\cancel{h}}}{\cancel{\mathrm{s}}}
\frac{60\cancel{\mathrm{s}}}{1\cancel{\mathrm{min}}}
\frac{60\cancel{\mathrm{min}}}{1\cancel{\mathrm{h}}}
= 3.6~\mathrm{C}$$

For example, if you draw 1 mA for 1 hour from a battery, you have used 1 mA &middot; 1 h = 1 mAh of charge. If you draw 2 mA for 5 hours, you have used 2 mA &middot; 5 h = 10 mAh.

You can approximate how long a battery will last by dividing its total charge (in mAh) by your nominal load current (in mA). Say you have a 1800 mAh battery, and you connect it to a 20 mA load:

$$ \require{cancel}
\frac{1800~\mathrm{mA\cdot h}}{20~\mathrm{mA}} =
\frac{1800\cancel{\mathrm{mA}}\cdot\mathrm{h}}{20\cancel{\mathrm{mA}}} =
90~\mathrm{h}
$$

This is an approximation because:


The charge capacity (the number measured in mAh) is determined by measuring how much charge can be removed from the battery before voltage drops to some arbitrarily selected level where the battery is considered "discharged". This may or may not be the threshold at which your circuit no longer functions. Battery manufacturers, wanting to make their batteries seem as good as possible, typically select a very low threshold voltage.
Assuming you are considering charge available only down to some voltage threshold, the actual charge available from the battery depends on temperature, and the rate at which you discharge it. Lower temperatures slow the chemical reaction in the battery, making it harder to extract charge. Higher rates of discharge increase losses in the battery, decreasing the voltage, thus hitting the "discharged" voltage threshold limit sooner.
The electric potential difference provided by the chemicals in the battery is actually constant; what makes the voltage decrease is the depletion of the chemicals around the electrodes and degradation of the electrodes and electrolyte. This is why battery voltage can recover after a period without use. So, the point at which the threshold voltage is reached can actually be quite complex to determine.


If you can find a good datasheet for your battery, it may give some insight into the parameters under which these calculations were made.