Correction: An earlier version of this story refered to the movie “Gran Torino” as “El Camino.” This version has been updated.

Rolf Lassgard stars as the curmudgeonly and lonely title character in “A Man Called Ove.” (Johan Bergmark/Music Box Films)

How many times have we heard that Scandinavians are the happiest people on the planet? If that’s true, it must be despite the protagonist of “A Man Called Ove,” a Swede so grouchy that he threatens to give his country a bad name.

Based on Swedish writer Fredrik Backman’s 2012 bestseller, the movie is formulaic in the manner of “St. Vincent” and “Gran Torino,” which were also about the curmudgeon next door: a fist-shaking geezer whose neighbors predictably help him find his heart. But this drama is a bit riskier and more intriguing.

For one thing, the movie, directed by Hannes Holm, manages to fuse melodrama with dark comedy and — no small feat — make it work. The funny bits take place in the present day as the bald, paunchy Ove (Rolf Lassgard) contemplates suicide. Friendless and jobless, he spends his days enforcing his neighborhood association’s pedantic rules, which means he yells at dog owners, hisses at stray cats and leaves rude notes on badly parked cars. The only person he cares about is his wife, and she’s dead. Still, he gazes at her photo with affection and brings flowers to her grave, where he conducts loving (if one-sided) conversations. The world is going to hell, he reasons, so he tells her he’ll be on his way to join her soon.

Ida Engvoll stars as Sonja and Filip Berg as young Ove. (Music Box Films)

The problem is, every time he tries to kill himself, something goes wrong. More often than not, he’s interrupted by the family that just moved in across the way. Parvaneh (Bahar Pars), an Iranian immigrant and pregnant mother of two, is impervious to Ove’s put-downs. Pretty soon the two of them start an unlikely friendship, as he teaches her how to drive while hilariously schooling her on the superiority of Saabs over Volvos.

The melodrama is delivered in bite-size flashbacks to Ove’s childhood, which was marked by tragedy, but also warmth. How did a well-adjusted kid grow up to be a downer who refers to every person he meets as “idiot”? We get our answer slowly, in bits and pieces, learning along the way how he met and fell for his effervescent wife Sonja (Ida Engvoll).

We’ve seen these poignant lessons before: Ove is destined to learn that he can’t do it all on his own and that life is still worth living. Yet the moving twists and turns of the love story and the bright comedy elevate an otherwise familiar story line. The mix of genres works, too. The flashbacks might be a little cheesy at times, but that’s appropriate considering they’re filtered through Ove’s bittersweet memories.

At times, the story is far-fetched. Ove keeps pushing people away, yet they continue to come back. The old man is lucky to be surrounded by so many gluttons for punishment. Maybe the Swedes, for all their reputation for contentment, simply have thicker skins.

PG-13. At Landmark’s E Street Cinema. Contains strong language and some disturbing images. In Swedish with subtitles. 116 minutes.