John Nathan-Turner started thinking as early as the summer of 1981 about the possibility of celebrating Doctor Who's twentieth anniversary with a special story. His initial proposal was that the transmission of season twenty should be brought forward to the autumn of 1982, and that of season twenty-one to the autumn of 1983, so that such a story could be slotted into the running order of the latter to coincide with the anniversary date of 23 November. This was rejected by his superiors, but Controller of BBC1 Alan Hart suggested instead that a one-off ninety minute programme might be produced to mark the anniversary.
As plans for this developed, Nathan-Turner and Eric Saward decided that they wanted a story featuring all five television Doctors to date as well as numerous companions and monsters. One early consideration was how to include the first Doctor, in view of the fact that William Hartnell had died in 1975. It was concluded that the best option would be to recast the part; the actor eventually chosen was Richard Hurndall, whom Nathan-Turner had seen in an episode of Blake's 7 and considered to resemble Hartnell.
Robert Holmes was the production team's first choice of writer to script the special. He drafted some possible scenarios for their consideration and then worked on a scene breakdown under the title The Six Doctors (reflecting the fact that the version of the first Doctor seen here would have been revealed at the end to be an android duplicate constructed by the Cybermen). This was eventually abandoned, and in November 1982 Terrance Dicks was commissioned to script a replacement story under the new title The Five Doctors.
One difficulty faced by the production team and writer was that, while both Patrick Troughton and Jon Pertwee readily agreed to appear in the special, Tom Baker eventually turned down the invitation. To ensure that the fourth Doctor was still represented in the programme, Nathan-Turner arranged for the incorporation of some scenes from Shada, the seventeenth season story that had been abandoned part-completed due to industrial action and never transmitted.
Nathan-Turner was keen to have each Doctor accompanied by at least one of his original companions. The initial intention was to team Susan (Carole Ann Ford) with the first Doctor, Victoria (Deborah Watling) with the second, Jo (Katy Manning) with the third, Sarah (Elisabeth Sladen) with the fourth and, naturally enough, Tegan (Janet Fielding) and Turlough (Mark Strickson) with the fifth. Watling and Manning ultimately proved to be unavailable, however, so in the event Sarah was paired with the third Doctor, and the Brigadier (Nicholas Courtney) with the second. Dicks also wrote in 'cameo appearances' by four other companions - Liz Shaw (Caroline John), Captain Yates (Richard Franklin), Jamie (Frazer Hines) and Zoe (Wendy Padbury) - who were confirmed only at a very late stage.
Nathan-Turner's initial choice of director for The Five Doctors was Waris Hussein, who had handled the series' first story, 100,000 BC, back in 1963. Hussein turned the offer down, however, and Peter Moffatt was then given the assignment instead. Filming and studio recording for the special was carried out during March 1983.
Nathan-Turner had hoped that the special would be transmitted in the UK on the actual anniversary date. This was not to be, however, as scheduling problems caused Hart to move it back to Friday 25 November, when it went out as a part of the annual Children in Need telethon fronted by presenter Terry Wogan. In some regions captions were run across the bottom of the screen during the transmission giving updates on the amounts of money pledged by viewers. The Five Doctors was actually premiered in the USA on 23 November, making it the first Doctor Who story ever to receive its initial screening outside the UK.