“Bernie,” Richard Linklater’s gaudily vibrant, at times morbidly funny true-crime story, takes place in the East Texas town of Carthage, which, at the time when sweet Bernie Tiede (Jack Black) murdered sour Mrs. Nugent (Shirley MacLaine), had a population of 6,500. To judge from the movie and the Texas Monthly article that inspired it, nearly everyone in Carthage loved Bernie, including the minister who after the shooting preached that Bernie “needs to be with God, and he needs to know that we are with him.” The preacher didn’t say that Bernie needed to be in heaven to be with God. In the movie, at least, he seems to suggest that Carthage would do just fine. Given the town’s Bernie boosters, it’s no wonder. “Bernie” grew out of a corrosively comic 1998 article by Skip Hollandsworth that jumps with memorable Carthage facts and flavor: a store called Boot Scootin’ Western Wear; a diner sign reading, “You Kill It, I’ll Cook It”; and Cadillacs veering off the road when the wealthy old widows who drive them miss the brakes. This is where Bernie blossomed and would still be in bloom if some had their way. Push past the local color, though, as Mr. Linklater does, and this starts to look like what it was: a sordid, bleak tale about two lonely people drawn to each other like colliding planets. Working from his and Mr. Hollandsworth’s script, Mr. Linklater doesn’t lead with the bummer side of the story but instead sets a broad, slightly uncomfortable comic tone that makes it difficult — intentionally, I think — to know if you’re meant to be laughing or recoiling. (Both are right.) Mr. Black can be an almost insistently demanding presence, and the moment he cuts loose in the movie, belting out a gospel song as if it’s a show tune, and then the reverse, he pulls you in hard. So it’s telling that Mr. Linklater opens the movie with Bernie showing mortuary students how to prettify a corpse. As he stands before his audience, he registers as both a director and performer, and a bit like a happy Frankenstein reanimating the dead. The relationship between Bernie and Mrs. Nugent was unlikely, but almost everything seems improbable about this bouncy child-man. The story slides into place when Bernie motors into Carthage for the first time, checking messages on his Jesus-adorned phone. Equipped with a mortuary degree, a country smile and a delicate, straight-back walk that suggests a prancing pony, he lands a job at a funeral home. Because he’s equally attentive to the living and the dead, he soon becomes an indispensable member of the community, whether singing in church or comforting the grieving. The widows take a special liking to him as he solicitously escorts them from their husbands’ graves like a gentleman caller, holding onto them in case they stumble. One day he takes the arm of one of the richest women in town, the newly widowed Marjorie Nugent. She doesn’t stumble — not at first anyway. She scowls at him when he later brings her sympathy flowers, and grimaces when he shows up with a gift basket. Ms. MacLaine, giving her face a strenuous, diverting workout, squares her jaw and tightly squinches her face, as if she were setting a spring trap and waiting for someone to take the bait. She looks battle ready, but there’s something hunted about Mrs. Nugent too, and both the actress and her director make certain you see the cracks in her defense and the woman — alone and lonely — that Bernie sees. The plot thickens ickily as Bernie and Mrs. Nugent become friendlier, a honeymoon period that Mr. Linklater, working with the cinematographer Dick Pope and the editor Sandra Adair, gives bright pop momentum. Bernie and Mrs. Nugent start going everywhere and doing everything together. He nudges the widow out of her solitary confinement so that she begins to enjoy what wealth brings, including Bernie’s attentions. There are lavish trips abroad, nights out and lots of nights in, as well as side-by-side spa massages. But as Bernie opens her world, Mrs. Nugent — out of fear, spite, pathology or plain meanness — tries to shrink his until he’s in her pocket. He doesn’t fit. It isn’t long before a district attorney, Danny Buck (Matthew McConaughey, showboating amusingly), has a case. Throughout, Mr. Linklater inserts intertitles that announce his thematic categories (“Was Bernie Gay?”) and brief interviews (scripted and not) with Bernie boosters, some played by actual townspeople. They’re textual annotations of a particularly queasy kind, and the interviews jump off the screen because these characters let it humorously hang out — and, man, do they love Bernie. These are the town gossips as Greek chorus, yet while they’re funny, sort of, there’s also something oppressive about these busybodies. They all have a lot to say, but in real life when the bad times came, and two of their own began flailing, these ostensibly comic, colorful types were as mute as the stuffed animals that seem to loom from every Carthage wall and make this funny Texas town look like one big taxidermy exhibit. “Bernie” is rated PG-13 (Parents strongly cautioned). Gun violence.