The show has had a dozen Doctors over its 54-year history, and this is one of those bittersweet moments when one lead actor hands over to another. At episode's end, viewers watched history unfold as Capaldi transformed — through a Time Lord process known as regeneration — into Jodie Whittaker, the first woman to play the part.

Before that comes a rollicking and poignant adventure that moves from the World War I trenches to the South Pole, features mysterious creatures made of glass and (of course) involves a jaunt in the Tardis, a time-and-space machine shaped like an old-fashioned British police phone box.

The episode loops back into the show's own history, featuring an appearance by the very first Doctor, a white-haired gent who appeared on TV screens in 1963. He was played by William Hartnell, who died in 1975; David Bradley fills the role here.

Gatiss has loved "Doctor Who" since childhood and has written for it since 2005.

He's better placed than almost anyone to explain the enduring allure of a show that survived early years of wobbly production values and a 16-year absence from screens between 1989 and 2005 to become a childhood touchstone, an emblem of British culture, and a money-making export for the BBC.

Partly, he says, it's due to the Doctor, an eccentric and "slightly off-kilter" hero. Partly it's "the randomness of the adventures," which have sent the Doctor to ancient Rome and the Stone Age, distant galaxies and the end of time.

And partly it's the show's "slightly ramshackle Britishness, in the very idea of an amazing space-time machine which looks like a beaten up old box."

Moffat, who also co-created detective series "Sherlock" with Gatiss, has no doubt about the show's place in television history. He told audience members at a recent preview screening that "Doctor Who" is "the greatest television show ever made."

"People change their view of the world and what they are capable of because of a silly show about a man who travels around in time and space in a police box," Moffat said.

"Count the scientists, the musicians, the scholars, the writers, the directors, the actors, who became what they are because of this show. Count, as you might say, the hearts that beat a little faster because of 'Doctor Who.' I don't even know what is in second place, but without doubt and by that most important measure 'Doctor Who' is the greatest television series ever made."

"Doctor Who" fans have become accustomed to changes of actor, and the shifts in mood that go with each new Doctor. The announcement that Whittaker (best known from detective series "Broadchurch") would be the next occupant of the Tardis was front-page news in Britain. Many fans were delighted, though some grumbled at the idea of a Time Lady.

Gatiss — currently working with Moffat on a new adaptation of "Dracula" — thinks the naysayers come mostly from that never-satisfied subset of fans "who will definitely watch it 28 times just to make sure they hate it."

"This is a series about an alien with two hearts who lives in a transcendental phone box — and yet somehow can't change sex?" he said. "That is not an argument for 2017."