Ian McKellen rages against the dying of the light as a 93-year-old Sherlock Holmes in “Mr. Holmes,” a slow but engrossing story in which Holmes must grapple with old age and senility to solve the secrets of his own mind. Memories from his last case, too painful to remember, haunt him as he potters around his English seaside home, keeping bees and trying various remedies for senility.

The main remedy he attempts derives from a plant he travels all the way to Japan to acquire. While there, he is led around, and possibly led astray, by a young man and his mother, whose connection to Holmes runs deeper than he realizes. He also visits the horrific site of Hiroshima (the story takes place right after World War II), where he finds inspiration in the rituals of the brokenhearted local people.

Photos | AI Film/Columbia Pictures

Photos | AI Film/Columbia Pictures

The chief enjoyment of this film is to simply watch McKellen, especially as he bonds with the plucky and intelligent young son of his housekeeper. The exceptionally bright boy bristles against the vocation and sensibilities of his mother, played with unshowy realism by Laura Linney. Hers is a bravely unflattering and unusually interesting part, and her relationship with her son gives Holmes a lot to think about. Young actor Milo Parker is mesmerizing as young Roger.

McKellen softens the egoism of Holmes, but not entirely. Not surprisingly, this magnificent actor strikes every note and shade in his masterful portrayal of a character of whom we never seem to tire. Through flashbacks, we see him at work on what proved to be his last case, in which he was commissioned by a husband to follow a distraught wife.

He solves the case, in a way, but the conclusion is tragic. With classic Holmes poise, he figures out what the wife, who is unable to recover emotionally from two miscarriages, has been up to. Throughout the film, Holmes works toward remembering his meeting with the wife, and is trying to write down a story of his own. He’s encouraged by the little boy, who eagerly reads the words of the man who quickly becomes his hero in the absence of his own father, lost in the war.

The film is structured through three timelines: the present in which Holmes is 93, his recent trip to Japan and 30 years in the past. The most distant flashbacks are undeniably enjoyable as he explains how Watson changed him on the page, leaving out the actual author, Arthur Conan Doyle, and giving us such amusing details as a change room in the true Baker Street location. Holmes is actually shown looking out of his real window at a crowd assembled across Baker Street. Also, similar to the BBC modern-day set “Sherlock” with Benedict Cumberbatch, an obsession with his legendary deerstalker hat and pipe remains.

While especially rewarding for Sherlock Holmes fans, “Mr. Holmes” is a beautifully portrayed story about aging and redemption that anyone can appreciate, no matter their level of Holmes mania. Indeed, by humanizing the illustrious detective, McKellen brings him away from the myth and into our real world, represented by the down-to-earth Linney character. Holmes’ mind is made whole when he reconciles these worlds and faces his past mistakes, and he is able to honor what he has lost.