The NBC series “Community” was created by Dan Harmon, a mad scientist of sitcoms—so divisive a figure that he was just run out of town by his own studio. (The show was re-upped for a fourth season, but Harmon was replaced with new showrunners.) Even amid the brutality of network TV production, this was a pretty shocking event, since “Community” is Dan Harmon, the way “Mad Men” is Matt Weiner. Set at a community college that is really a stage for wildly inventive genre experiments, it’s a comedy that’s at once alienating and warm, a sitcom lover’s sitcom that attracts the kind of fans that the media scholar Henry Jenkins once described, with admiration, as “frighteningly ‘out of control,’ undisciplined and unrepentant, rogue readers.”

Matt Smith as Doctor Who, a pale, puppyish genius who attracts super-fans. Illustration by Owen Freeman

In other words, not everyone. So perhaps it’s no coincidence that “Community” ’s excellent third season, which ended two weeks ago, featured a season-long meditation on the pains and pleasures of cult fanhood, structured around an homage to one of the greatest science-fiction shows: “Doctor Who.” The key to this exploration was the character of Abed Nadir, played by Danny Pudi with the gaze of an amused basilisk. Abed, who has Asperger’s syndrome and dreams of making documentaries, is in one sense a familiar sitcom character, the gentle alien observer—like Latka, in “Taxi.” But with each season he has drifted closer to the show’s center, replacing its ostensible hero, the smart-ass Jeff, and injecting “Community” with his super-fan enthusiasms, which range from Batman to “My Dinner with André.”

As Abed emerged, “Community” became a bit of a science-fiction show itself, the kind of series in which, in the season’s signature moment, a tossed die splits a dinner party into six alternate realities. In another plot this season, Abed and his best friend, Troy, constructed a Holodeck-like space in their apartment, which they called the Dreamatorium. Inside that green-and-yellow grid, Abed and Troy played out imaginary plots of their favorite show, “Inspector Spacetime,” which stars an “infinity knight” in a bowler hat, and his associate, Constable Reginald (Reggie) Wigglesworth.

“Inspector Spacetime” is, of course, an affectionate tribute to “Doctor Who,” the long-running series that helped create our modern breed of Abeds and Dan Harmons—the sort of difficult obsessives who make original things and then get fired. “Doctor Who” débuted on the BBC in 1963, three years before “Star Trek” (and the day after Kennedy was assassinated). The show’s eponymous hero was (and is) a Time Lord, capable of jumping through time and space. He does so in the whirling TARDIS, which looks like a bright-blue phone booth but is as large as a mansion once you step inside. When near death, he generates a new body, conveniently played by a new actor (something NBC surely wishes were a tradition for showrunners). There have also been many “companions,” often plucky females—most famously Sarah Jane Smith (Elisabeth Sladen)—as well as enemies, like those Nazi-ish pepper pots the Daleks. The show used the shabbiest possible effects, plus a fly-by-night attitude toward narrative logic, although its low budget was as much a feature as a bug: it made something out of nothing, much the way Abed and Troy constructed their Dreamatorium engine out of cardboard tubes and a funnel.

After twenty-six years on the air—and intense devotion from fans—“Doctor Who” was cancelled, in 1989. Then, in 2005, it was “rebooted” by the BBC, and overseen, for the first four seasons, by Russell T. Davies, one of whose earliest memories, at the age of three, was of the 1966 season. In 2010, Steven Moffat, best known for his modern reinvention of “Sherlock,” took over, and Matt Smith became the eleventh Doctor.

Before I caught up on the last two seasons, my expectations were low. I anticipated something like the seventies-era series that I faintly remembered: a goofy, juvenile thrill ride. (I haven’t watched Davies’s version, but a fellow TV critic told me that she was so attached to his “Who” that she wasn’t watching Moffat’s.) The original “Who” dwelt on pure sci-fi obsessions, abstract questions of how society is organized and the line between humans and machines. But, as deeply as fans loved the show, its themes were rarely emotional. Instead, it jumped from Aztec civilization to Mars, as much an educational show for children as an adult narrative, with a British-colonialist view of the universe. (So many savages, so little time.) The series’ most striking feature was the Doctor himself: in contrast to “Star Trek” ’s Kirk—the Kennedyesque leader of a diverse society—the early Doctor Who was an alien iconoclast with two hearts and a universe-wide Eurail Pass. For a certain breed of viewer, this was an intoxicating ideal: the know-it-all whose streak of melancholy—or prickly rage, depending on who was Who—had to be honored, because he actually did know everything.

Though that show had its charms, I was surprised, and delighted, to find that the modern “Doctor Who” has a very different emphasis: it’s a show about relationships, in an epic and mythological vein. Certainly, the show has plenty of the classic “Doctor Who” pleasures, albeit with more sophisticated effects: there are seafaring pirates; a metallic England floating on a giant “Star Whale”; and a factory full of avatar-laborers whose faces melt off like goo. The Doctor himself is a pale, puppyish genius who shares several qualities with Moffat’s modernized Sherlock Holmes, including fashion affectations (he insists that bow ties are cool, then fezzes, then cowboy hats) and a Professor-from-“Gilligan’s Island” allure. The show’s strength, however, is not its one-off stories but its longer arcs, a structural breakthrough of “The X-Files,” which modelled the notion that episodic TV could be woven together with powerful, season-long themes, inspiring the more complex breed of modern shows, both sci-fi and regular-fi.

Each contemporary sci-fi series has its own obsessions; Moffat’s “Doctor Who” ’s is time travel, a venerable trope from H. G. Wells’s time machine to “Lost” ’s Dharma Initiative. (Interestingly, it’s also a theme in non-speculative TV, which came unstuck in time around 2008, on series as disparate as “Desperate Housewives,” “How I Met Your Mother,” and “Mad Men.” My own know-it-all theory is that this was a reaction to the appearance of the DVR, that time machine for TV fans.) The old “Doctor Who” dealt with time primarily as a mode of transportation: it jumped in a linear fashion, usually no more than one adventure per series. On the new “Who,” time travel is a philosophical and an emotional challenge: it braids together flashbacks, alternate realities, and so on, exploring with poetic verve some truly wrenching themes of mortality and loss.

“Trouble is, it’s all back to front,” laments Doctor Who’s soul mate, River Song (played by the badass Alex Kingston). “My past is his future.” Song is Doctor Who’s future wife; or maybe she’s his past wife. They’ve been travelling in time, but in opposite directions. “Every time we meet, I know him more,” she says. “He knows me less. I live for the days when I see him—but I know that every time I do he’ll be one step further away.” Song’s story, which carries through seasons five and six, is only one of the show’s meditations on this theme: there’s also the Doctor’s companion Amelia (Amy) Pond, an orphan who met the “raggedy Doctor” when she was seven, only to have him disappear for twelve years, then come back, then leave for two more. Amy’s true love, Rory, waits for her for two thousand years. In one episode, an embittered version of Amy is left alone for thirty-six more years. In others, two sets of parents miss out on their child’s entire upbringing. But if abandonment is a recurring motif, the show remains romantic about human nature. In one lovely moment, the TARDIS itself is transferred into a female body and marvels to Doctor Who about the experience: “Are all people like this? So much bigger on the inside.”

This would be awfully gloopy—a melodrama like “The Lake House”—if it were all that the show did. Luckily, “Doctor Who” is also quite funny, as well as playful about its own conceit. In an episode last season, a character held Doctor Who at gunpoint, insisting that he help her escape from the cops: “You’ve got a time machine. I’ve got a gun. What the hell? Let’s kill Hitler!” Perhaps the most endearing, and least realistic, quality of the new “Doctor Who” is its optimism. Despite having lived for centuries, Doctor Who is an enthusiast, not a cynic, unlike some vampires I could mention. Although he’s literally been there and done that, Smith’s Who is a Tigger of high spirits, a characterization nicely shaded by moments of darker self-questioning. “I took you with me because I was vain,” he confesses to Amy in one scene. “I wanted to be adored.” This is one of the most provocative aspects of the recent “Doctor Who”: since Amy was enraptured by the Doctor as a child, her relationship to the Doctor is essentially that of a fan, who spends years drawing pictures and building models of his adventures, her low-tech version of a Dreamatorium. This generous devotion balances, but never quite erases, the show’s sadder themes; on “Doctor Who” (and on “Community,” too) the fan’s experience of loyalty and loss is its own, legitimate form of romantic love.

On the verge of débuting his late, lamented sci-fi series “Firefly,” which was cancelled after less than one season of Fox mismanagement, Joss Whedon remarked that his goal was not to create “grownup” TV but to “invade people’s dreams”—to create mythologies, which last so much longer than the mortal form of a TV series. Cult shows, such as “Doctor Who” and “Community,” often have this quality: they shrug off the condescension that people have toward their “lower” genres, using their constraints to find a greater freedom. When you look at a show like that from a distance, it might seem too narrow to contain much of interest. But it’s so much larger when you’re on the inside. ♦