“Goon” represents two noteworthy achievements. One is that it’s a very funny R-rated sports comedy, which is not common. The other is that it stars Seann William Scott — heretofore best known as the aggressively jerky Stifler in the “American Pie” films — as an endearing character you actually want to root for. Could Scott play a genuine leading man in a mainstream, big-studio comedy? Here is strong evidence that he could!

Scott plays Doug Glatt, a Massachusetts underachiever who is recruited to play for a minor-league hockey team. He is offered this position not because he’s good at hockey — he’s never even been on skates — but because he’s a terrific fighter. No matter the size of his opponent, Doug can lay him out with a punch or two. (This comes up a lot in his current job as a bar bouncer.) As his new coach says, “You’ve been touched by the fist of God.”

And so Doug winds up playing for a semi-pro team in Halifax, coming into the game when someone on the other team is deemed to be in need of a smackdown. He’s also assigned to protect his teammate Xavier Laflamme (Marc-Andre Grondin), who is gun-shy after taking a beating from the league’s most legendary brute, Ross “the Boss” Rhea (Liev Schreiber). Doug, now called Doug “the Thug,” dreams of one day fighting Ross himself.

To someone who isn’t a hockey fan, the idea of recruiting a player who’s bad at the sport but great at fighting sounds like satire. The movie — which is loosely based on fact, as recounted in Adam Frattasio and Doug Smith’s book “Goon: The True Story of An Unlikely Journey into Minor League” — certainly plays up that aspect, adding to it the fact that Doug is not by nature a combative or aggressive person. He’s actually quite gentle and polite. (When his bouncer job required him to rough somebody up, he usually apologized first.) He has a skill, and he’ll cheerfully use it, but he doesn’t go looking for reasons.

But what keeps this from being a one-joke film is the way the story develops from there. Doug becomes a legitimate member of the team, a rag-tag group of misfits with an abysmal win-loss record who desperately need a new attitude. Doug gets a love interest, a local girl (Allison Pill) with a thing for hockey players, and starts to feel, for once in his life, like he’s living up to his potential. “Goon” becomes, in other words, an exuberant underdog sports comedy, and a good one at that.

The screenplay is by Evan Goldberg (“Superbad”) and actor Jay Baruchel, who also steals scenes as Doug’s magnificently vulgar best friend. They find abundant humor in the relentless mocking in the locker room and the absurd violence on the ice (which director Michael Dowse shoots lovingly), as well as in the sport’s crazy fans and off-kilter commentators. I wouldn’t have thought a movie about violence would be this happy, or that a movie starring Seann William Scott would be this good-natured, but here we are. It’s practically a miracle on ice.

B+ (1 hr., 32 min.; R, pervasive harsh profanity, vulgarity and sexual dialogue, and a lot of strong violence.)