At one point in “The Lady in the Van,” Roger Allam, as Rufus, a neighbor of writer Alan Bennett’s on their tony London street, remarks that he’d seen a West End stage monologue that Bennett had written and was starring in. When Deborah Findlay, as Rufus’ wife Pauline, remarks that she couldn’t recall what the play was about, Rufus replies, “It’s about him—everything he writes is about him.”

That self-deprecatory authorial insight applies to Nicholas Hytner’s film as well. Maggie Smith is undoubtedly the main selling point of the adaptation of Bennett’s 1999 play (Hytner’s third filmization of a Bennett effort, after “The Madness of King George” and “The History Boys”). She won plaudits for the role when she played it on the stage in London (also under Hytner’s direction), and she’ll win them for recreating the part on screen now. But though Smith steals every scene, “The Lady in the Van” isn’t really about Mary Shepherd, the cantankerous old woman who lived in a van parked in the driveway of Bennett’s upscale Camden Town house for some fifteen years. It’s actually about the effect that her presence had on the author.

That’s why the other major characters here are two versions of Bennett, both played via camera trickery by Alex Jennings. One is the man Bennett, the reserved, shy fellow who interacts with Shepherd and who in effect defers to her peremptory demands for attention. The other is Bennett the writer, who chides his other self for his submissive manner while nonetheless taking a keen interest on the Bennett-Shepherd connection as grist for a possible literary piece—the one this film represents. (The multiplication increases when the actual Bennett shows up at the very end, when a plaque is put up remembering Shepherd.)

Of course, in telling that story—which is inextricably connected with Bennett’s relationship with his own mother (Gwen Taylor), herself a difficult woman with whose increasing fragility the writer also has to deal—the narrative delves through the writer’s queries of relatives and acquaintances into Shepherd’s past, which is meant to explain her present state. She turns out once to have been a piano prodigy who studied with none other than Alfred Cortot. She entered a Catholic convent, where the sternness of the regimen kept her from any contact with the keyboard. And later she was involved in a tragic accident for which she continues to feel responsible; the weight of guilt has combined with her religious conviction to lead to her homeless, friendless circumstances.

Jennings gives a nicely understated performance as the dual (and sometimes dueling) Bennetts, whose closeted homosexuality is revealed without fanfare as one element of his persona—and the supporting cast, including Allam and the inimitable Frances de la Tour as another of the neighbors, the widow of composer Ralph Vaughan Williams, offer engaging moments. (There are fleeting cameos by the likes of Dominic Cooper and James Corden, who had parts in “The History Boys” and make a nod to its author in return.) Only the usually reliable Jim Broadbent disappoints, going overboard as an ex-cop who periodically shows up to harass Shepherd.

But all of them, as well as the excellent physical production (production design by John Beard, art direction by Tim Blake, sets by Niamh Coulter, costumes by Natalie Ward, with cinematography by Andrew Dunn and editing by Tariq Anwar), are basically just window dressing for the performance of Smith, who dominates the film as completely as she did “The Prime of Miss Jean Brodie” years ago or her scenes in “Downton Abbey” today. Indeed, although she’s dressed in rags rather than the elegant garb of the dowager countess, her manner is just as imperious here. But Bennett’s script offers her opportunities for other attitudes as well. She adopts an almost regal mien as she’s put on an ambulance lift for a trip to the hospital late in the picture, and captures the poignancy of the woman in sequences when she’s emotionally moved by the music she once loved—pieces by Chopin and Schubert, which Bennett integrates cunningly into the narrative (and composer George Fenton does likewise in his background score), as well as her hysteria when in the throes of religious mania or in fear of her harasser’s threats.

“The Lady in the Van” stumbles toward the close with a detour into what might be termed curdled magic realism in a cemetery. Apart from that, however, it’s another clever construct by Alan Bennett, which gives Maggie Smith a grand opportunity to shine. The playwright who began his career with “Beyond the Fringe” has really proven a blessing to actors—not just Smith but Nigel Hawthorne and Richard Griffiths; and Hytner has done them all proud, too.