It was Eric Saward who proposed that the 'new' twenty-third season should have a linking plot in which the Doctor was placed on trial by the Time Lords for his interference in other worlds - a reflection of the fact that Doctor Who itself was still effectively on trial at this point. John Nathan-Turner quickly approved this, and the two worked out a format for the story.
Drawing inspiration from Dickens' A Christmas Carol, they decided to structure the plot so that the trial evidence came from three different stages of the Doctor's life - past, present and future - and everything was wrapped up in a fourth segment at the end. Two figures appearing throughout the season would be the Valeyard (prosecuting counsel) and the Inquisitor (judge), for whom the production team finalised detailed character outlines at the beginning of July 1985.
The writers originally chosen to script the season were Robert Holmes, Philip Martin, David Halliwell and Jack Trevor Story. The intention was that Holmes and Martin would each provide a four-part segment of evidence; that Halliwell and Story would contribute two episodes apiece of a further four-part segment; and that Holmes would then be responsible for the two-part conclusion. They were asked to avoid including anything overtly horrific in their scripts and to make the story fun and entertaining - an approach designed to meet Controller Michael Grade's wish, expressed in a short meeting with Nathan-Turner, for the series to become less violent and more humorous.
Work progressed relatively smoothly on the segments assigned to Holmes and Martin but problems arose on those entrusted to Halliwell and Story, who were both eventually paid off. The production team commissioned a replacement third segment from Christopher H Bidmead, but this was also rejected. A further replacement was then commissioned from Sapphire and Steel creator P J Hammond, but this too came to nothing. Pip and Jane Baker were the next writers approached to fill the four-part gap, and their submission finally met with the production team's approval. Commissioned at the beginning of March 1986, the scripts had to be written within the space of a month in view of the shortage of time now remaining.
December 1985 had, meanwhile, seen well-known entertainer Bonnie Langford being cast by Nathan-Turner to play the new companion, Mel, who would be introduced part-way through the season. Her popularity with younger viewers was seen by the producer as having the potential to boost Doctor Who's audience. Part Eight would be the last on which Nicola Bryant worked as she had reached a mutual agreement with the production team to leave at this point.
In early February 1986, Robert Holmes was commissioned as planned to provide the story's concluding two-part segment. Shortly after this, however, he fell seriously ill and found it increasingly difficult to work. Another complication arose at around this time when Saward decided to quit the production team and return to freelance writing, which left the series temporarily without a script editor.
Holmes grew steadily weaker and died in mid-May 1986, having completed only a rough draft of the first episode of the closing segment and nothing at all beyond an initial outline of the second. Saward was then persuaded by Nathan-Turner to return to the project to take over where Holmes had left off. Subsequently however the two men had a major disagreement over the story's ending. The original idea apparently agreed between Saward and Nathan-Turner had been to close on a cliffhanger, with the Doctor and the Valeyard locked in mortal combat in the time vortex, but the producer later vetoed this on the grounds that it was too down-beat and would end the series on an inconclusive note if BBC management then decided to cancel it permanently. Incensed by Nathan-Turner's change of mind, Saward withdrew permission for his script to be used. The producer therefore brought in Pip and Jane Baker to write a completely new final episode as an emergency measure.
Despite the changes made to the series' style and content in the wake of the cancellation of the original season twenty-three, Controller of BBC1 Michael Grade remained badly disposed toward Doctor Who. He did eventually give the go-ahead for a further season to be produced - but only on condition that a different actor was given the lead role. Colin Baker was offered the chance to appear in the first four episodes of the twenty-fourth season in a story to explain the Doctor's regeneration, but he declined to do so, so The Trial of a Time Lord would unexpectedly stand as his last appearance in the series.
The news that he would not be returning as the Doctor was broken to the general public in early December 1986. Many of the series' fans were incensed by the treatment that Baker had received from the BBC. There was however clearly no prospect of Grade reversing his decision, so another new Doctor would have to be cast to take Doctor Who into the late eighties. Nathan-Turner had acceded to his superiors' request to inform Baker of his ousting from the series only on the understanding that he himself would finally be allowed to move on to a different project, so it seemed that season twenty-four would find newcomers both in front of and behind the cameras...