how was the doctor able to regenerate 13 times
Regeneration (Doctor Who) In "The Lodger", after the Eleventh Doctor shows Craig who he is, he points to his face and says, "Eleventh". However, in "The Name of the Doctor", when the Doctor rescues Clara from inside his own time stream, they both see another figure that Clara doesn't recognise. The Doctor then reveals that this is a past incarnation that he deemed unworthy of the name "Doctor" due to the atrocities he committed during the Time War, and only accepted him after learning the truth of how the war ended ("The Day of the Doctor").[45] Ultimately, in "The Time of the Doctor" the Eleventh Doctor reveals that, counting the War Doctor and the Tenth's aborted regeneration, he is actually in his final incarnation, reaching a point where he is dying of old age after centuries of conflict with the Daleks and others on the planet Trenzalore. However, at the behest of Clara, the Time Lords grant the Doctor a new regeneration cycle, allowing a thirteenth regeneration into an incarnation known as the Twelfth Doctor.