Comedy is hard. Farce is harder. The momentum and lunacy need to keep building. The characters’ cluelessness needs to be endearing, but they can’t come off as imbeciles – the audience will turn against them entirely. The outrageous hijinks can’t be pushed too hard or the whole delicate conceit is apt to collapse into desperate chaos

Wonder of wonders, then, that Shawn Levy, the director of such middle-of-the-road fare as “Cheaper by the Dozen” and “The Pink Panther,” and Josh Klausner, one of 12 credited screenwriters who worked on “Shrek the 3rd,” should turn out to be such gifted practitioners of this very tricky genre in “Date Night.”

The film plays like a modern-day variation on Martin Scorsese’s night-in-hell comedy “After Hours,” complete with mistaken identities, surprise cameos and one of the more deranged car chases in recent memory. That there is a beating heart at the center of all this – a surprisingly sweet “comedy of re-marriage,” about a frustrated middle-age couple who find a way to get their mojo back – makes it all the more appealing.

Steve Carrell and Tina Fey play Phil and Claire Foster, a married couple living with their two children in New Jersey, who are sent reeling when they learn that their closest friends (Kristen Wiig and Mark Ruffalo) are splitting. Has our own marriage hit the same brick wall, they wonder? Phil hatches a spur-of-the-moment plan, a “date night” in New York City, where they will dine at the hippest new downtown restaurant. They don’t have a reservation, but if they arrive early enough, he’s confident they can land a table.

The opening 15 minutes or so of “Date Night” are the weakest. Levy takes his time ramping up the story, and the jokes – especially about Phil attending Claire’s mostly female book club, where they read weepy stories of female empowerment set in the Middle East – don’t quite connect. But once the two of them arrive at Claw, the uber-trendy hotspot where the Black-Eyed Peas’ will.i.am is dining at another table, the movie hits its stride.

Phil and Claire are at first turned away from the overcrowded Claw. But when another couple’s name is called repeatedly by the hostess, he brazenly assumes their identity and snaps up the open table. A case of very dangerous mistaken identity ensues – the couple that was supposed to be eating at that table was in possession of a flash drive that a fiendish mobster (Ray Liotta) and two crooked cops (Jimmi Simpson and Common) are determined to get back – but one of the funniest things about the movie is how outraged everyone becomes when Phil and Claire reveal that they stole the reservation. In contemporary New York City, political corruption and organized crime are to be expected and even tolerated, but a reservation at a fancy hotspot is sacrosanct.

With the bad guys in hot pursuit, Claire and Phil take off on a race across New York City, in a plot that doesn’t always make a tremendous amount of sense.

But the movie keeps finding new ways to surprise us, especially with the introduction of Holbrooke (Mark Wahlberg), a perpetually shirtless Lothario whose pecs make Phil want to kill himself. A fabulously wealthy security expert, Holbrooke still seems to harbor a crush on Claire from when she showed him a bunch of houses in upstate New York.

Using his soft-voice, rippling abs and his easy-does-it stride to terrific effect, Wahlberg has a great time sending up his own studly persona – much to the comic dismay of Carrell’s Phil. An even bigger treat is the brief appearance of J.B. Smoove, the hilarious actor who plays Leon on “Curb Your Enthusiasm,” who shows up as a cab driver who literally locks bumpers with the Fosters.

Quibble all you want that the movie, even at 88 minutes, feels a little padded and that Taraji P. Henson – as a detective who seems to be the only person who believes the Fosters’ story – is wasted. the time Carrell and Fey are writhing on a stripper pole in the back room of a seedy private strip club for a bisexual district attorney (William Fincter), the movie has entered its own realm of inspired delirium.

Considerable credit to the leads: Carrell and Fey have long had a gift for witty self-deprecation, but they also bring an unmistakable humanity to these characters and their troubled relationship. When the two of them break out into a familiar domestic argument – she’s frustrated by how much work she has to do, he’s annoyed that she never seems to have any faith that he’ll come through for her – they capture a sense of genuine pathos and disappointment.

No matter how deranged the circumstances, the actors keep us rooted to reality.