The BBC show starring Benedict Cumberbatch; the CBS series starring Lucy Liu and Jonny Lee Miller; the Guy Ritchie movies starring Robert Downey Jr.: The speed at which Sherlock Holmes has become a thing again never ceases to shock this particular Sherlockian. Once upon a time, the detective was a musty, dusty figure, vaguely familiar to the public at large but fixated upon by a small coterie of Victoriana-obsessed irregulars. Interest in him occasionally flared up — the 1980s PBS series starring Jeremy Brett and the 1940s films starring Basil Rathbone were two high points — but never anything like this. Sherlock Holmes is totally cool again, which warms my dorky heart.

In Bill Condon’s Mr. Holmes, Ian McKellen gives one of his finest performances, as an aging Holmes reflecting on the past and contending with his legacy. The film clearly owes some debt to the recent rise in interest in Arthur Conan Doyle’s infamous detective, for it takes as a given Holmes’s cool cerebral detachment, his bemused distance from the petty affairs of us overemotional mortals. When a bystander recognizes Holmes at a train station early on, it’s not meant to be ironic; the film doesn’t have to remind us who Sherlock Holmes is or what he’s like. It plays, at times, like fan fiction, which it sort of is. (It was based on Mitch Cullin’s slim, elegant 2005 novel A Slight Trick of the Mind, which at the time was among a brief wave of new Holmes novels that included Caleb Carr’s The Italian Secretary and Michael Chabon’s The Final Solution.)

But it’s excellent fan fiction all the same. Playing the frail detective, McKellen is a shocking sight. It’s not just the makeup job, but something he captures with his expression, a wide-eyed glower that looks out at us with both disdain and surprise. One actually tenses up at seeing him, worried this man might break down before us. There’s a thematic reason for this, too: This man, we sense, has lived too long past his time. In the film’s present, set in 1947, Holmes is in his 90s, a sour old grape now retired for three decades in the Sussex countryside, where he devotes himself to beekeeping, botany, and mentoring Roger (Milo Parker), the young son of his widowed housekeeper Mrs. Munro (Laura Linney). Something is killing the bees, however, and as Holmes and Roger contend with that seemingly minor mystery, the frail detective grapples with his decaying mind to write down the facts of his final case, which happened many years ago.

The case — about a melancholy wife (Hattie Morahan) who has fallen under the spell of a glass organ, or armonica, and appears to be hearing voices — comes to Holmes sometime around the end of World War I, after Watson’s departure. It plays out in flashback as the detective, trying his hand for once at telling his own story, writes down the particulars, cutting out whenever he pauses to try and recall what happened next. It’s less a typical act of deduction — there isn’t much poking around carpets and stairwells, looking for the odd clue — and more one of obsessive pursuit. Holmes follows the woman around London, not unlike Jimmy Stewart in Alfred Hitchcock’s Vertigo. (At one point, she stands outside a taxidermist shop named Ambrose Chapell, a tip of the hat to Hitchcock’s The Man Who Knew Too Much, a film that could have easily lent its title to this one.)

Meanwhile, we also get glimpses of the elderly Holmes’s recent visit to Japan, to explore a rare herb that allegedly cures senility and to confer with fellow botanist Masuo Umezaki (Zak Shukor). The herb, called prickly ash, turns out to grow in a devastated corner of Hiroshima, and Umezaki takes Holmes to harvest it one day from an endless black, bombed-out wasteland. (“Perhaps it’s life reasserting itself,” they speculate.) We wonder, though, if the Japanese botanist, who claims to be a big fan of Holmes’s work, might have an ulterior motive for inviting the great detective all the way to Japan.

The multiple mysteries of Mr. Holmes — the bees, the haunted woman, the visit to Japan — are intertwined in ways that tantalizingly suggest a grand, unifying solution. Here’s where it gets tricky: Condon and screenwriter Jeffrey Hatcher have to keep us guessing and engrossed, even though the mystery is an unorthodox, possibly even symbolic one. We have to be okay with the possibility that there might not be a solution.

Spoiler alert: There is one, sort of. But Mr. Holmes isn’t so much about nefarious deeds as it is about complicated people. The two postwar timelines are not coincidental. Holmes’s struggle with his own memory aligns with the broader question of historical memory. He watches a man mourning his family in Hiroshima, and it perplexes him — not because he doesn’t understand the horror of war but because he can’t quite grasp the ritual of grief. Nor, for that matter, can he grasp the great lie of fiction, the stories we tell ourselves to make sense of the unexplainable. He complains about the liberties Watson took with the truth in his tales. At one point, Holmes even goes into a movie theater and sees a sensationalized film version of the very case he’s trying to recall. Elsewhere, Mrs. Munro asks Roger if he remembers his father, who died in the war; the boy says he does, but his answer makes it clear that all he remembers is a picture.

Here’s where the existing legacy of Holmes perhaps comes into play the most. Conan Doyle’s prose, the very atmosphere he wove with his words, was a soothing blend of reason and prescriptive virtue, the contented language of an empire at its peak. Holmes, for all his idiosyncrasies, was very much a product of that time. He couldn’t grasp the messy business of human desire, or grief, or inchoate longing. Mr. Holmes brings him face to face with the things he cannot fathom, or control. It’s a gripping little tale, to be sure, but it’s more than that. Somewhere in its tangle of timelines, false starts, and red herrings is a great truth about the unsolvable mystery of the human soul.