Outside the Barbican Centre, in the City of London, steel crowd barriers define a narrow path to and from the theatre’s stage door. Polite notices ask for consideration of the neighbors. These measures, which have been in place since early August, have done little to contain the public ardor for Benedict Cumberbatch, who ends a wildly successful three-month stint as Hamlet at the Barbican this week. (Tickets to the performances sold out within seven hours, and a live broadcast to movie theatres earlier this month attracted nearly a quarter of a million viewers worldwide. Encore screenings are likely to continue until the sun swallows the Earth.)

On a recent weeknight, the fans were pressed against the barriers, quivering with expectation. Some had seen the night’s performance, whereas others had shown up in hopes of catching one of Cumberbatch’s occasional streetside cameos. One young British man announced, somewhat defiantly, that his loyalties lay with Ciarán Hinds, the “Game of Thrones” star who portrays Claudius in the Barbican production. “What is it with Cumberbatch?” he asked a nearby group of American women, sounding genuinely curious. The women craned their necks around him, angling for a better view of the stage door.

Cast members trickled out. Kobna Holdbrook-Smith, who plays Laertes, chatted about craft on the edges of the crowd. Jim Norton, who plays Polonius, treated the longing behind the barriers with sympathetic concern, as if it were a mild medical condition. “I do hope Ben will come out,” he muttered as he signed programs. “I think he will.” Hinds emerged, looking harried. “I’m very late,” he said apologetically as he strode by. (“Ciarán!” his acolyte wailed.)

Cumberbatch, who first gained international fame in 2010, for his leading role in the BBC series “Sherlock,” has since become a phenomenon of his own. His audience’s enthusiasm is partly circumstantial: the character of Sherlock Holmes has inspired extreme fan behavior since Arthur Conan Doyle first tried to kill him off, in 1893, and “Sherlock” ’s lovingly irreverent modernization has spread the virus to new generations. Cumberbatch also had the mixed fortune of being a bachelor at the time of his career breakthrough (he has since married the actress and theatre director Sophie Hunter; their first son was born in June). His illusory availability, combined with his exotically imperfect looks and self-deprecating charm, launched a thousand adoring memes.

But the furor around Cumberbatch also has a lot to do with real talent, as his turn as Hamlet makes clear. Onstage at the Barbican, supported by a uniformly excellent cast, Cumberbatch transforms himself into a grief-stricken rich kid from a messed-up family. Like other fine performers, he has the ability to pull his audiences out of their restless, itchy, needy selves and into a larger story, and he applies himself to the job with vigor; after more than seventy shows, he was still crying, sniffling, and sweating his way through the two-hour-plus performance. If the purpose of theatre, as David Mamet wrote, is to “inspire cleansing awe,” then actors, at their best, are secular servants to the ineffable. Offstage and offscreen, fans pursue them not just for a taste of fame but also to get within selfie range of transcendence.

The trouble is that when actors come to see themselves not as well-paid intermediaries but as actual deities (and everything in popular culture encourages them to do so), their power fades. Cumberbatch, who is the child of two actors and grew up in the London arts community, seems unusually alert to this danger. Although he does invite attention, sometimes joyfully so, he acknowledges that his cult is not of his creation. “I’ve been around for ten or fifteen years before this happened and I wasn’t on any lists of the millionth most attractive,” he told Dave Davies of “Fresh Air” earlier this year. “I think it is a reflection of the work and hopefully how I come across when I’m talking about the work, rather than what I actually have got.” For the past several weeks, he has ended his curtain calls at the Barbican with a plea for aid to Syrian migrants, exhorting audience members to leave their change in donation buckets in the foyer.

On the sidewalk outside the theatre, with most of the company now accounted for, the tension mounted. The stage door opened again, revealing not Cumberbatch but Andrew Scott, who portrays the arch-villain Moriarty on “Sherlock.” The crowd issued a collective squeal, thrilled by the unexpected crossover. Scott, who had been in the audience that evening, gamely added his signature to a fusillade of programs. Finally, after a long pause, Cumberbatch appeared in a crewneck sweater and glasses, looking as weary as any other thirty-nine-year-old after a long evening’s work. The crowd screamed, tried to consider the neighbors, and then, as Cumberbatch neared the barriers, seemed to condense and rise up, as if about to crest over itself. Here was a chance for a personal benediction.

Cumberbatch, silhouetted in the glow of camera phones, began to work his way down the line, head bowed over programs and posters. Less then a minute later, however, he straightened, raised a hand, and turned back, disappearing into the theatre. The doors closed and the fans groaned. After a few moments, they began to disperse into the dark.