Tom McCarthy’s a good actor—you might not recognize the name, but his face would be familiar—but on the evidence of his first two pictures he’s an even better writer-director. “The Station Agent” (2003) was a wry, intelligent, strangely affecting study of three lonely people becoming unlikely friends in a coastal New Jersey town. Now, in “The Visitor,” he takes on the hot-button issue of undocumented immigrants and uses it not as the springboard for a heavy-handed screed on one side or the other, but as the basis for a sharp, moving, insightful character study of a man who’s fallen into an emotional slump and is revived from it by the friendships he forges with a trio of illegal aliens. This is a lovely, quietly touching film that approaches a provocative and topical subject with dramatic sensitivity and graceful understatement.

But McCarthy isn’t the sole hero. He’s fortunate in having as his star Richard Jenkins, another fellow whose face you’ll know (perhaps from “Six Feet Under,” where he played the ghostly father) even if you won’t recognize the name—a character actor who here has the part of a lifetime, much as Terry O’Quinn did in the very different “Stepfather” two decades ago.

Jenkins is simply amazing as Walter Vale, an economics professor at a Connecticut university who’s professionally burnt out after years of rote teaching and personally bereft following the death of his wife. He’s a man emotionally at sea, a fact demonstrated not only in his perfunctory attitude toward his students (the script nails the academic environment) but his failed attempts to move on with his life—encapsulated in his blundering efforts to learn to play the piano as a sort of tribute to his spouse, who was a concert artist. Forced to attend a conference in New York City to present a paper in place of an incapacitated colleague, his putative co-author, he’s surprised to find his little-used apartment occupied by Syrian drummer Tarek (Haaz Sleiman) and Senegalese jewelry-maker Zainab (Danai Gurira), who were apparently tricked into “renting” the place from a scam artist.

Rather than kicking the pair out, however, Walter allows them to stay, and gradually builds a bond with Tarek, a gregarious fellow who encourages him to take up the drums, a pastime that Walter finds enormously liberating. Unfortunately, during a trip back from the park where they’ve joined street musicians in impromptu concerts, Tarek is arrested and taken to a detention center, where only Vale can visit him even after his mother Mouna (Hiam Abbass), who’d fled from Syria after the murder of her journalist husband but never succeeded in gaining asylum for either herself or her son, arrives from Detroit. Walter takes her in too, and as he visits Tarek to support him personally as well as legally through the efforts of an immigration lawyer he’s hired, develops a chaste but very real romantic bond with her.

As it gets into these final stages, the didactic quality of McCarthy’s script becomes more pronounced, but even here Jenkins maintains his restraint even though by now Walter has broken through his shell. The intent is clearly to show the arbitrary, insensitive nature of the whole detention system, which Vale comes to understand as he tries to help his friend (and we along with him). But though McCarthy’s criticism is obvious, Jenkins exhibits the character’s reaction to a Kafkaesque system—as well as Walter’s attraction to Mouna—with welcome subtlety. And the film ends not with the standard sort of false Hollywood uplift, but a bittersweet finale that’s true to Vale’s transformation without suggesting that all his woes—and society’s—have been resolved.

And though Jenkins is unquestionably the standout in the cast, the others are also first-rate. Sleiman is winningly extroverted and Gurira convincingly wary as his unlikely apartment-mates, while Abbass projects dignity and grace as Tarek’s beautiful mother. McCarthy also secures strong turns from those (including some non-professionals) in smaller roles, with Marian Seldes a standout as the last of Walter’s many piano teachers. Though this is a modest production, the technical credits are all solid, with Olivier Bokelberg’s cinematography straightforward but quietly eloquent.

Like “The Station Agent” (and another picture of a closed-off man’s emotional emergence, Alexander Payne’s “About Schmidt”), “The Visitor” is a film that sneaks up on you rather than demanding attention in the usual Hollywood fashion, and it’s captured you even before you realize it. That’s the cunning of McCarthy’s approach, and it’s the key to Jenkins’ superb performance as well. It’s early in the year, but award voters should remember their work come December and January.