The Doctor, like other Time Lords, began with a natural life cycle of 12 regenerations (13 incarnations); however, it is possible for a Time Lord to have additional regenerations, such as the Master receiving extra lives during the Time War, as referenced in "Utopia". Also, it is possible for a Time Lord to live fewer incarnations than the 13 typical, for example, by being killed again during regeneration (which was faked in "The Impossible Astronaut") or if killed by certain poisons ("Let's Kill Hitler").
It is also possible to use one's regeneration energy to heal another. River did this in "Let's Kill Hitler", giving up all her future regenerations to cure the Eleventh Doctor of the poison she herself had given him. The Eleventh Doctor did the same -- to a very much lesser extent -- when he used some regeneration energy to heal River's broken wrist in "The Angels Take Manhattan".
In "The Time of the Doctor", when the Eleventh Doctor was dying of old age & had no regenerations left, the Time Lords gave him a new cycle of regenerations. He used the first of these to regenerate into the Twelfth Doctor & later ("Kill the Moon") said he was unsure whether or not there was now any limit to the number of times he could regenerate. Rassilon, who himself does have unlimited regenerations ("The Five Doctors"), was likewise unsure whether or not the Doctor could regenerate indefinitely ("Hell Bent").