After reaching a nadir with roles in stuff like “Jack and Jill,” Al Pacino has managed a late-career resurgence by taking parts in some solid telefilms and smaller movies with interesting directors like Barry Levinson (“The Humbling”), Dan Fogelman (“Danny Collins”) and now David Gordon Green. Green, meanwhile, has restored his reputation after the studio bombs—“The Sitter” and “Your Highness”—that followed his successful move to mainstream fare with “Pineapple Success” by returning to his indie roots with “Prince Avalanche” and “Joe.” One wishes that their collaboration might have proven as fruitful as the one Green managed with Nicolas Cage, another star lately down on his luck; but such is not to be.

Not that “Manglehorn” is terrible. The slender character study, tinged with the sort of homespun magic realism that marked Greene’s early films, has moments of genuine poetry and tenderness. And Pacino tries valiantly—too strenuously, perhaps, since his underplaying always has a hint of overplaying to it—to keep his boisterous, booming personality in check. But both director and actor are ultimately undermined by a script (by Paul Logan) that makes its points in a labored fashion at war with the subtlety they’re straining for.

Angelo Manglehorn is an aging locksmith in a Texas town who’s pretty much erected an emotional barrier around himself, grieving for decades over the fact that his unwillingness to commit drove away Clara, the one woman he ever truly loved. He still pines away for her, writing her long letters (read by Pacino in voiceover) that are always returned to his mailbox unopened. He’s estranged from his son Jacob (Chris Messina), an investment broker, and his only real connections are with his granddaughter (Skyler Gasper), his beloved cat Fanny, and a sunny bank teller named Dawn (Holly Hunter), with whom he chats amiably while making his regular deposits.

Green creates a mood of loneliness and regret as he and cameraman Tim Orr follows Mangelhorn ambling about town, stopping for breakfast or making house calls to open safes or unlock car doors. The script also pays ample attention to his concern for Fanny, who’s diagnosed with a bowel obstruction due to a swallowed key and requires surgery (which is fairly explicitly shown), and his conversations with Dawn at the bank. But he also inserts bits of dreamlike peculiarity to create a vaguely otherworldly atmosphere. The most notable are a slow-motion sequence of a six-car crash that Mangelhorn walks past as the drivers either argue with one another or sit on the ground awaiting help, and a sweetly baffling sequence in which a man begins singing in the bank with a flower in his hand, only to be joined after a minute or so by the bank manager, presumably the object of his affection. Even the swarm of bees continuously hovering at Manglehorn’s mailbox has a hallucinatory touch.

In its later stages, however, the film gives in to the rickety nature of the script’s construction, and Pacino lets loose a couple times too often. In a confrontation with his son, whose market manipulations have apparently caught up with him, and a run-in with Gary (Harmony Korine), a nervy young fellow he once coached in Little League, at the fellow’s massage parlor, the actor bellows in his customary fashion, undermining the subdued persona he’s gone to such lengths to construct; and after a disastrous first date with Dawn, in which his prattling about Clara’s virtues sends the poor girl scrambling to get away, Manglehorn decides finally to unlock the cage he’s built for himself by destroying all the memorabilia about his lost love he’s been mooning over—down to trashing the boat on which he’d planned to sail away with her into the sunset. The upshot of it all is to make the trajectory of the narrative all too obvious and bring its symbolism of locks and keys home with sledgehammer force.

Nevertheless “Mangelhorn” is a close call. It shows that Pacino is capable of restrained, affecting acting, and that Green remains a sensitive observer of small-town mores. Hunter, moreover, gives a gentle, touching performance as a woman desperate for affection, though both Korine and Messina go overboard. Fanny is a lovely quizzical cat, and one only hopes that it was a stand-in that endured the surgery. The evocative music by Explosions in the Sky and David Wingo is also a definite asset.

But it’s a pity that in the end Logan’s heavy-handed script lets Green and Pacino down.