Writing "Midnight" was developed alongside "
Turn Left", with each episode reducing the role of one of the programme's two regular leads:
Donna appears only in the pre-credits sequence and final scene of "Midnight", while the
Tenth Doctor has a similarly limited role in "Turn Left". Stephen James Walker later described "Midnight" as a "companion-lite" episode.
Russell T Davies said that the story was partly inspired by the
Star Trek: The Next Generation episode "
Darmok". Davies wrote "Midnight" to replace a planned story by
Tom Macrae that was dropped because it was considered too similar to another script that had recently been filmed. He conceived the episode in response to "
Voyage of the Damned", which he felt had shown the best in human nature, and instead chose to focus on its darker side and on the way people turn on one another. He later said that he wanted a run of darker episodes to match the tone of
Steven Moffat's "
Silence in the Library" and "
Forest of the Dead", and described the idea for "Midnight" as one that "wouldn't go away". Davies was particularly interested in imitation as a source of unease, observing that it could be "mocking, irritating and unnerving" and that repeated mimicry "drives you mad". He also conceived the Doctor's predicament in two parts: the threat of possession and the passengers' growing paranoia. As Davies put it, "It's very rare to see the Doctor out of control, but he cannot control people." The final script ran to sixty pages, most of it taken up by a single sequence—Scene 9—which alone extended to forty-four pages and covered the passengers' escalating conversation and paranoia aboard the shuttle.
Casting Lesley Sharp was cast as Sky Silvestry, the episode's principal guest role. She had previously worked with Russell T Davies twice before, and Davies said that he had her in mind while writing the part. Sharp said that she was keen to appear in
Doctor Who, as she admired the direction the revived series had taken and considered it "wonderfully written and executed".
David Troughton was a late replacement for
Sam Kelly as Professor Hobbes after Kelly broke his leg and had to withdraw from production. He joined the cast in
Cardiff with just two days' notice. Other guest cast included
Daniel Ryan, who had previously expressed interest in appearing in
Doctor Who, and
Colin Morgan, for whom "Midnight" was his second television role.
Filming Filming took place over two weeks, from 27 November to 11 December 2007. Most of the episode was shot in Studio 6 at
Upper Boat Studios, with the opening and closing scenes filmed separately at a spa resort in
Newport. Because those scenes featured
Catherine Tate, who was simultaneously working on the Doctor-lite episode "
Turn Left", they were recorded on the final day of shooting. The episode's main shuttle sequence, Scene 9, was structured as a long real-time scene and was divided into several smaller sections during filming, each charting a different stage in the passengers' growing paranoia. Because of the scene's continuity, it was almost possible to perform the sequence in one complete take. To film the overlapping dialogue, director
Alice Troughton recorded multiple takes of the same material: one performed normally, followed by others in which all but one actor mimed their lines. This allowed the dialogue to be isolated and combined more precisely in the final sound mix.
Murray Gold completed the score in April 2008, when re-dubbing and the episode's remaining post-production work were also finalised. ==Broadcast and reception==