Alternate timeline (The Name of the Doctor)

An alternate timeline in which the Doctor died during the Siege of Trenzalore and the planet became a battlefield graveyard initially existed, (TV: The Name of the Doctor) before Clara Oswald and the Time Lords changed history. (TV: The Time of the Doctor)

Background
It was originally believed by the Doctor that Gallifrey and the Time Lords were destroyed by the War Doctor and the Moment at the end of the Last Great Time War. (TV: The End of the World, Dalek, The Name of the Doctor) However, during a crisis with the Zygons, the Moment brought the War Doctor, the Tenth Doctor and the Eleventh Doctor together to show the War Doctor what would happen if he went through with his plan. With the encouragement of Clara Oswald, all incarnations of the Doctor teamed up to save Gallifrey by placing it into a pocket universe. Due to their timelines being out of sync, only the Eleventh Doctor would remember this and his previous selves left and soon they lost their memories of saving their people. (TV: The Day of the Doctor)

Due to fears that the Doctor would speak his true name and release the Time Lords from their pocket universe at Trenzalore, the Kovarian Chapter of the Church went rogue in an attempt to prevent the Doctor from ever reaching Trenzalore so the siege wouldn't take place. (TV: The Time of the Doctor) The Chapter, or the Silence as it generally became known, attempted to blow up the Doctor's TARDIS to kill him (TV: The Pandorica Opens, The Big Bang, The Time of the Doctor) and to "engineer the perfect psychopath" in River Song to assassinate the Doctor. (TV: Day of the Moon, Closing Time, The Wedding of River Song, The Time of the Doctor) However, these efforts all failed and played a role in the Doctor reaching Trenzalore, creating a temporal paradox. (TV: The Time of the Doctor)

Having become aware of the Silence's plan to kill him and that it was a fixed point in time, (TV: The Almost People, Let's Kill Hitler) the Doctor sought answers for why he had to die before going to Lake Silencio where history stated that River would kill him. The Doctor learned from Dorium Maldovar of the Silence's prophecy of the Question: "on the fields of Trenzalore at the Fall of the Eleventh when no creature can speak falsely or fail to answer a question will be asked, a question that must never, ever be answered." This question, which Dorium called "the oldest question in the universe, hidden in plain sight" was "Doctor Who?" or a request for the Doctor's real name. Eventually, with the help of River and the Teselecta, the Doctor faked his death so that all but a few believed him to be gone. (TV: The Wedding of River Song)

The Siege of Trenzalore
After a message was broadcast throughout all of time and space, the Eleventh Doctor and "half the universe" followed the signal to a Level 2 human colony planet where the Doctor discovered a residual crack in the universe that the message was being broadcast through. With the help of Handles, the Doctor translated the message which was "Doctor Who?" The Doctor learned from Tasha Lem that the planet was Trenzalore and realised that this was the fulfillment of the prophecy he had received from Dorium. More, the Doctor realised that the Time Lords, trapped in their pocket universe, were attempting to get out. If the Doctor spoke his true name, the Time Lords would know that it was safe to return and would come through the crack. However, with "half the universe" surrounding the planet, the return of the Time Lords would spark a new time war. If the Doctor left the planet, Tasha would have it destroyed by the Papal Mainframe to prevent this outcome.

At a standstill, the Doctor remained on Trenzalore to defend the town of Christmas during the ensuing siege. Over the next nine hundred years, the Doctor defended the planet from his various enemies. (TV: The Time of the Doctor)

The death of the Doctor
Despite allying with the Silence when the siege turned into a full battle, the Doctor's defence on Trenzalore ultimately failed. At the end of his life and with no more regenerations left to him, the Doctor died. The Doctor was laid to rest in his TARDIS which was left upon the planet's surface to die. (TV: The Time of the Doctor, The Name of the Doctor)

Along with the Doctor, millions died in the siege, "a minor skirmish" for the Doctor, but enough to permanently end him due to the Doctor's intent to defend Trenzalore to the end and his inability to regenerate. The population of the planet was exterminated and the entire surface became one big battlefield graveyard. Trenzalore itself transformed from a beautiful habitable world into a barren wasteland with a cracked molten surface and lost its rings and its moons. The Time Lords and their crack disappeared. (TV: The Name of the Doctor)

The Doctor visits his tomb
In its efforts to negate all of the Doctor's victories, the Great Intelligence managed to locate the Doctor's tomb in the battlefield graveyard on Trenzalore. In order to access the Doctor's TARDIS which now experienced a "size leak" as it was dying, the Great Intelligence set out to lure an earlier version of the Doctor to his tomb. Using Clarence DeMarco, the Paternoster Gang and Clara, the Great Intelligence was able to pass the space-time coordinates for the Doctor's tomb on Trenzalore to him.

In order to save his friends, the Doctor reluctantly crossed his own time stream in a big way by taking his own TARDIS to the future Trenzalore. During a confrontation between the Doctor and the Great Intelligence, a data ghost of River Song, manifesting through a psychic "conference call" link with Clara, opened the TARDIS doors. Inside, the Doctor, his friends and the Great Intelligence found not a body, but the Doctor's time stream. To destroy the Doctor, the Great Intelligence entered the time stream, but Clara followed it to save the Doctor. After saying a final goodbye to River, the Doctor entered his own time stream to rescue Clara, encountering his greatest secret. Following Clara's rescue, the Doctor departed his time stream and the future Trenzalore with his friends. (TV: The Name of the Doctor)

An accepted fate
After seeing his tomb on Trenzalore, the Eleventh Doctor came to accept that his fate would be that he would die there despite not knowing the circumstances. After saving Gallifrey and the Time Lords alongside the War Doctor and the Tenth Doctor, the Eleventh Doctor told his predecessor that he had seen their tomb on Trenzalore. Despite the Tenth Doctor's protests, the Eleventh Doctor insisted that their fate was to die in battle on Trenzalore amongst millions and that they could not stop it. (TV: The Day of the Doctor)

Negation
The Doctor eventually arrived on Trenzalore in response to the Question's broadcast throughout time and space and initiated the Siege of Trenzalore. However, this time both the Doctor and Clara knew what would happen since they had seen the future Trenzalore. Despite Clara's attempts to convince him otherwise, the Doctor refused to leave the planet and did not believe that he could change the future that he had witnessed.

After nine hundred years and having fended off all but the Daleks, the Doctor became old, frail and weak and was dying of old age, out of regenerations with which to continue his life. With the Daleks having broken through the final defences at Christmas, Tasha Lem brought Clara from her own time to be with the Doctor so that he would not die alone. With a Dalek saucer descending and the Daleks demanding the Doctor's surrender, the Doctor went out to meet his fate, continuing to believe that he could not change the future. The Doctor admitted that when there were still Time Lords he could have, but alone he had no chance.

In a desperate act, Clara pleaded with the Time Lords through the crack in the universe to save the Doctor and help him change the future. As the Daleks prepared to kill the Doctor, the Time Lords intervened to save the Doctor by moving the crack into the sky above Christmas and sent the Doctor a new regeneration cycle through the crack. The Doctor immediately underwent an explosive regeneration and used the regeneration energy and resulting shock wave to destroy the attacking Dalek forces. With Trenzalore saved and the crack closed, the Doctor departed the planet in his TARDIS and shortly afterwards regenerated into the Twelfth Doctor, changing the future and negating this timeline. (TV: The Time of the Doctor)

Behind the scenes

 * In Doctor Who Magazine, writer and showrunner Steven Moffat said that the Doctor had explained to him that The Time of the Doctor didn't actually make The Name of the Doctor an alternate timeline."I can change the future so long as the future has not already been established as part of my own past. I can't rescue Amy and Rory because I already know that I didn't.

But what do I know about Trenzalore? There's a big monument that looks very like my TARDIS. There's a temporal fissure leading to my timeline. Maybe it's my grave. Maybe, one day, it's my burial ground. Maybe it is something else entirely, and we got it all wrong. Don’t know. Don't plan to find out for as long as possible.

The main thing is, Clara still jumped into my time stream, and ended up helping me through all of my life. All that is established, unchanged – but there's wiggle room!"

- The Doctor