This is one of the pleasanter surprises of the summer. “Central Intelligence” is by no means a great buddy action-comedy—it’s far too silly and derivative for that. But in a dumb, likable way it offers some smiles and even a few genuine laughs. And if it sometimes miscalculates in the action department (especially in a concluding fight scene), at least it doesn’t go completely overboard in that respect.

The co-scripters, actor Ike Barinholtz and David Stassen (who are both connected with “The Mindy Project”), as well as their collaborator Rawson Marshall Thurber (who also directs), are obviously fans of “The In-Laws” and “Charade,” movies from which they’ve borrowed liberally. Their part homage, part re-invention doesn’t match either of those two models, but those earlier pictures provide a solid template, and it winds up providing one of the best vehicles yet for both of its stars, Kevin Hart and Dwayne “The Rock” Johnson.

Their characters, Calvin Joyner and Bob Stone, first appear in a high-school prologue, where Calvin, the big man on his Baltimore campus, comes to overweight geek Robbie’s aid when he’s the target of a malicious prank by an obnoxious bully. Twenty years later, Calvin is a depressed accountant just passed over for promotion, dreading the twentieth reunion at Central High that his wife Maggie (Danielle Nicolet), his erstwhile campus sweetheart who’s now a successful lawyer, is pressuring him to attend, when he’s contacted out of the blue by Bob and finds the once-dumpy Robbie transformed into a brawny dude with a good-natured attitude, but also able to take care of bullies without breaking a sweat whenever necessary.

The plot kicks in when, after their night out (which includes a nostalgic visit to the school), Bob asks Calvin to use his skill in “forensic accounting” to check on what he describes as a payroll problem. The figures that come up, however, look suspiciously like bidding in an underground auction dealing with some very expensive, probably illegal stuff. Matters escalate the next day when no-nonsense CIA agent Harris (Amy Ryan) and her underlings show up at Calvin’s house looking for Bob, whom she describes as an agent who’s gone rogue, running off, after the death of his partner during a mission, with some data he intends to sell to a notorious bad-guy. Harris suggests that Bob might actually have killed his partner to secure the information.

One needn’t take the details of that background material too seriously; the gobbledygook is just an excuse to throw the nervous Calvin together with big, daredevil Bob in a series of manic adventures as they evade pursuers and slowly bond until they can figure out where the trade-off of the data is to occur. The effort to leave open the possibility that Bob might actually be the deranged traitor Harris believes him to be doesn’t really work (having Johnson glare into the camera as though he might be guilty is a clumsy ploy), but in compensation the screenplay throws in a number of digressions that have little to do with the basic plot but are mostly amusing. A visit to a marriage counselor by the Joyners is a highlight, for example, though it comes out of left field. (By contrast, a sequence in which Bob briefly ends up in Harris’ custody is one of those clumsy action interruptions, and another in which Bob gets Calvin to admit his deepest desire doesn’t come off, primarily because his admission is so banal.) Everything culminates in a confrontation that explains everything (though in an entirely implausible fashion) while cementing the guys’ friendship, followed by the inevitable reunion postscript in which Bob finally comes to terms with his mistreatment two decades earlier.

“Central Intelligence” isn’t as smart as the recent “Spy” was, but it’s similar in its easygoing spoofing of the genre and its good casting choices. Hart’s intensity has often been irritating in his pairings with the likes of Ice Cube and Will Ferrell, but here his shtick is far less grating, and while Johnson doesn’t entirely shed the stiffness that’s marked his acting to date, he’s becoming more comfortable on screen. He also proves willing to do almost anything for a laugh, undercutting his he-man persona while simultaneously employing it to the hilt. Ryan and Nicolet have pretty thankless material to deal with, but Aaron Paul makes one of Calvin’s co-workers so genuinely scummy—the only real instance of raunchiness in the movie—that you cheer when he gets his just deserts. There are also a couple of turns by surprise guest stars, both of whom have connections with Thurber from past work together; in each case they score strongly.

On the technical side, the film is fine, with widescreen cinematography by Barry Peterson that gives both Hart and Johnson the space to execute their routines to best effect and editing by Michael L. Sales that gives the routines a good rhythm. Many will want to stay around for the outtakes that are part of the closing credits; some are pretty funny.

This isn’t as clever a buddy-action comedy as Shane Black’s “The Nice Guys,” and its helicopter arrival scene at the end merely reminds you that “The In-Laws,” from which the bit taken, remains a far superior comedy of mismatched partners. But as long as you keep your expectations fairly low, you should find “Central Intelligence” a reasonably agreeable way to waste a couple of hours.