The Doctor's trial (The War Games)

In the Doctor's first trial involving the Time Lords, he was charged with breaching the non-interference policy (TV: The War Games) and tried by three members of the High Council, Adelphi, Goth, and Socra. (PROSE: The Legacy of Gallifrey)

Origins
Alongside his granddaughter, Susan Foreman, the First Doctor stole a TARDIS, which they used to depart their home planet of Gallifrey. (TV: The Name of the Doctor) As the Doctor claimed to Ian Chesterton and Barbara Wright, he and Susan were exiles wandering through time as they had been cut off from their planet. (TV: An Unearthly Child) Furthermore, as the Second Doctor explained to Jamie McCrimmon and Zoe Heriot, he was not content to merely observe the universe as the other Time Lords did and so, motivated by boredom, proceeded to explore time and space personally. While doing so, he acknowledged that he had a tendency to "get involved" and understood that the Time Lords did not approve of his actions, despite the people he had helped during his travels. (TV: The War Games)

The trial
Judging the return of the participants in the War Games too tough a task, the Second Doctor decided to send a hypercube containing all the relevant information to the Time Lords so that they could help with the matter, although the War Chief quite forcibly advised against it. (TV: The War Games) Authorities from Gallifrey were dispatched to the planet, including no lesser Time Lords than the Keeper (PROSE: Doctor Who and the Doomsday Weapon) and three members of the High Council, (PROSE: The Three Doctors, The Legacy of Gallifrey) one of them being Goth, (PROSE: The Legacy of Gallifrey) who was also an agent of the Celestial Intervention Agency, (PROSE: Future Imperfect) yet unknown to the Presidency. (PROSE: The Legacy of Gallifrey)

The Doctor briefly attempted to evade the Time Lords but they took control of the TARDIS and landed it on Gallifrey. The Doctor, Jamie and Zoe witnessed the War Lord being sentenced before Jamie and Zoe were placed in a force field and the Doctor was escorted to his own trial.

The Time Lords accused the Doctor of breaking their laws of non-interference. The Doctor admitted the crime and reiterated his pride in doing so, rather than merely observing the evil in the universe. He then asked for a Thought Channel to show the evil he fought. He showed the Time Lords the Quarks and the Yeti. When they seemed unimpressed he showed them the Ice Warriors, the Cybermen and the Daleks. He ended by saying that he may be guilty of interference, but they were guilty of passivity against such evil. With the trial over, the Time Lords considered the charges whilst the Doctor played cards.

Allowed to bid farewell to Jamie and Zoe they convince him to try and escape but they are intercepted by a group of Time Lords. The Doctor says goodbye to both of them before they are returned to their own times with their memories wiped of all but their first encounter with the Doctor. The Doctor watched on a screen as Zoe is returned to the Wheel and Jamie fights a Redcoat.

The Time Lords then delivered their verdict; they accepted that there was evil in the universe that must be fought and the Doctor had a part to play. They noted his affinity to Earth and told him he would be exiled there as well as forced to regenerate. The Time Lords gave the Doctor several choices for his new body but he declined all of them. He then lost his speech and began to swirl into nothingness. (TV: The War Games)

Aftermath and legacy
Before the Doctor's sentence could be carried out, the Celestial Intervention Agency intervened and turned him into their "hired gun". (PROSE: World Game) He would work in this capacity for some time. (TV: The Two Doctors et al.) However, when the CIA needed to cover up his visit to Space Station Camera it was decided that his exile should be enforced. (PROSE: A Brief History of Time Lords) Although the Doctor escaped again before a regeneration could be enforced and lived in luxury for some time before falling into a trap and finally regenerating into his third incarnation. (COMIC: The Night Walkers)

Both Jamie (COMIC: The World Shapers) and Zoe were able to regain some of their memories of travelling with the Doctor. (AUDIO: Echoes of Grey) Additionally, after the Doctor had saved the Time Lords from certain doom they lifted his exile and restored his knowledge of the TARDIS. (TV: The Three Doctors) This trial was referenced during the Sixth Doctor's trial for meddling, in which the sentence was deemed by the prosecutor to be too lenient. (TV: The Mysterious Planet)

Alternate timelines
In a parallel universe, the Second Doctor chose one of the faces offered to him and became a brutal dictator on Earth. (PROSE: Timewyrm: Revelation)

Behind the scenes
The concept of a Season 6B set between The War Games and Spearhead from Space was a long held fan theory and established as narrative fact by TV Comic.

In the fan film, Devious, the Doctor was extracted by the CIA halfway through his regeneration creating the "Second-and-a-Halfth Doctor" played by Tony Garner. He went on several adventures before completing his regeneration.