“Bug” isn’t a horror film, nor is it a straight-up psychological thriller. It dwells instead in the twitchy, uncomfortable realm between those styles, with elements of a weird love story thrown in for good measure. Does it work? Yes, in a way. It’s hard to imagine how a movie with such jarring, disparate ingredients could succeed 100 percent, but “Exorcist” director William Friedkin — as qualified as anyone to take a stab at it — nearly pulls it off.

Adapted by Tracy Letts from his own play, the film takes place almost entirely in a seedy Oklahoma motel room, the home of Agnes (Ashley Judd), a waitress at a lesbian honky-tonk bar and the ex-wife of a convict. The con, Jerry (Harry Connick Jr.), has just been paroled, making the lonely, beaten-down woman more anxious than usual. She drinks vodka and snorts cocaine with the gusto of someone who doesn’t expect to live much longer, or who doesn’t have much to live for anyway.

Agnes’ friend and co-worker, R.C. (Lynn Collins), introduces her to Peter (Michael Shannon), a polite, awkward drifter who doesn’t drink or do drugs. They all hang out at the motel room for a while until R.C. goes home, leaving Agnes and Peter to get acquainted. Neither is looking for love, or even sex; companionship will do for now.

Peter says he’s more intuitive than most people, able to discern secrets and to see things most people don’t notice. He demonstrates this “vision” metaphorically by getting Agnes to admit some of her past sorrows — she and Jerry had a son who disappeared 10 years ago — and then literally by finding tiny bugs in the bed sheets. Aphids, he says, and they bite. And they’re everywhere. Do aphids really bite? Never mind. Can Agnes see them too? Never mind!

She sees them soon enough, all over herself and the room, and thus begins the film’s descent into unsettling craziness. Peter is your garden-variety paranoid nutcase, ranting about conspiracy theories and other madness, yet Michael Shannon — reprising his role from the London and New York productions — plays him with such reasonable-sounding passion that you almost believe him.

Agnes is certainly a convert. The film suggests, painfully, that we seek out elaborate conspiracy theories to explain things like 9/11 and the Oklahoma City bombing because they provide better, more satisfying explanations for events that are otherwise too monstrous to contemplate. You can use paranoia to explain away all your problems and fears, and that’s what a wounded soul like Agnes needs.

Judd and Shannon are both fearless and unselfconscious in their portrayals of these unhinged characters, and that’s where the film walks a perilous tightrope. Their increasingly impassioned rants probably play better on the theatrical stage, where the audience can be caught up in the moment more readily due to the immediacy of live theater. With film, it’s much harder to establish that intimacy, and thus much more likely that someone in the audience is going to laugh at histrionic lines like “I am the super mother bug!” And once one person laughs, it’s hard to take it seriously anymore.

That’s not a fault of the film, necessarily. The performances, the directing, and the editing all suggest that everyone involved was fully committed to treating the onscreen madness with dead seriousness. If you can be absorbed in it the way Friedkin intended, you’ll find yourself suitably disturbed by the horrific and inevitable conclusion.

B (1 hr., 42 min.; R, abundant harsh profanity, brief strong violence, disturbing images, brief strong sexuality and nudity, a lot of nonsexual nudity.)