BOTTOM LINE A good-hearted comedy about fatherhood and family, though it’s not exactly family-friendly.

Every now and then, a featherweight comedy comes along that punches above its class and hits you where you least expect. “Daddy’s Home” is one of them. The story of two fathers battling for the hearts of one family, it’s a modest, small-scale movie that nevertheless says quite a bit about modern fatherhood. It’s also very funny, if not entirely family-friendly.

Will Ferrell plays Brad Taggart, a big-hearted doofus married to Sarah (an appealing Linda Cardellini) and helping raise her two children, Dylan and Megan (Owen Wilder Vaccaro and Scarlett Estevez). A radio executive at The Panda, “America’s No. 3 smooth jazz station,” Brad may not cut the coolest figure, but he’s caring and sensitive, almost to a fault.

Enter Mark Wahlberg, perfectly cast as the swaggering Dusty Mayron, the kids’ biological dad. An ex-military type who rides an Indian motorcycle, Dusty has been only an absent threat — until now. Despite Sarah’s reassurances, Brad knows that guys like Dusty are catnip to women and kids alike.

What follows is a duel between two alpha-male types: the freewheeling rogue and the dependable suburbanite. It’s a simple and thoroughly satisfying premise that allows Ferrell and Wahlberg to recreate much the same dorky/manly dynamic as they did in the buddy-comedy “The Other Guys.” Director Sean Anders (“That’s My Boy”) sets up some fine slapstick sequences (Brad’s attempt to recreate his old skateboarding skills ends badly), but it’s the psych-out maneuvers that get the biggest laughs. After Dusty builds the kids a tree house, Brad buys them a pony.

“Daddy’s Home” contains more than a little suggestive humor. Thomas Haden Church, as Brad’s tone-deaf boss, tells several off-color tales about his past wives while Bobby Cannavale plays an inappropriate fertility doctor. Most of this material is quite funny, and none of it is truly tasteless. Still, omitting it — and perhaps giving more time to those all-important children — might have put this likable comedy within reach of classic status, perhaps up near “Mr. Mom.”

Conceived and co-written by Brad Burns (brother of Valley Stream filmmaker Ed Burns), “Daddy’s Home” does a deft job of teaching its heroes worthwhile lessons without resorting to contrivances. It assembles a fine support cast (Hannibal Burress plays a moocher named Griff) and sets up small jokes that later pay off big — something comedies like this rarely do successfully. Those details lift “Daddy’s Home” above the average throwaway. You wouldn’t want your youngest children to see it, but the other dads in your crowd might appreciate an invitation.