Tony Gilroy wrote the three Jason Bourne movies and “Michael Clayton,” so he knows from twisty espionage stories. But “Duplicity” marks the first time he’s really injected much humor into his work, and it’s a welcome variation. Not everyone has to be as serious as Jason Bourne all the time.

It helps that Gilroy has two witty, urbane actors as his leads — Clive Owen and Julia Roberts, who combined have the charisma and screen presence of a dozen regular actors. They play MI6 agent Ray Koval and CIA agent Claire Stenwick, spies who first meet in 2003 at the U.S. consulate in Dubai. Flirtation leads to hotel-room shenanigans, but the one-night stand ends badly for one of them.

We jump ahead five years. Ray and Claire, neither employed by the government any longer, are reunited when both get jobs in New York City with multinational corporations, which are just as ruthless about spying on one another as nations are. Claire is actually a double agent, employed by Burkett & Randle to look for internal malfeasance and also, secretly, by B&R’s chief competitor, Equikrom, to spy on B&R. (The companies are both the type that make a million products, everything from dog food to shampoo.) Ray is the new guy at Equikrom, hired specifically to help find out what B&R’s top-secret new product is.

Ray and Claire’s first meeting in New York finds them both as sharp as ever, equally adept at lying and subterfuge, bickering like Cary Grant and Katharine Hepburn (except I think the roles are reversed). Gradually, we learn more about the nature of their relationship, and about the con job they’re interested in perpetrating. But of course the problem with being a spy is that you have a lot of trust issues when it comes to personal relationships, and those issues are only magnified when the other person is a spy, too.

Gilroy carefully parcels out flashbacks, set in places like Rome, London, and Miami, to show what occurred between the Dubai hookup and the present. These sequences reveal key bits of information, so deciding when to deploy them is crucial, making the storytelling device the sort of feat that only an experienced screenwriter would dare attempt, like the triple lutz in figure skating. Audiences enjoy being toyed with, especially in movies about espionage, but only if the twists are clever and don’t involve cheating. Gilroy handles it expertly (no surprise there), and maintains a light, jaunty tone.

Clive Owen, who doesn’t get to smile very often in movies, seems to be having a grand time as Ray. He really sinks his teeth into a scene where he poses as a Tennessee-raised doctor in order to cozy up to an unsuspecting informant; you get the feeling his being Southern is totally unnecessary except insofar as it gives Owen a chance to do an accent — a morsel for the audience, nothing more. Julia Roberts, whose grin is far more familiar to us, proves a fine sparring partner and romantic interest for Owen (much more so than when they previously worked together, in “Closer”).

Owen and Roberts are the main attraction, but the supporting cast adds plenty of flavor, most notably Tom Wilkinson and Paul Giamatti as the heads of B&R and Equikrom, bitter rivals to whom we are first introduced when they fight in slow motion on an airport tarmac over the opening credits. This is one of several amusing directorial touches by Gilroy (it’s only his second time as director, after “Michael Clayton”), and it shows again his knack for piquing a viewer’s interest: Who are these men? Why are they fighting? Why is slow motion so funny? Could I really watch Paul Giamatti and Tom Wilkinson fight in slow motion all day long? Yes, yes, I believe I could.

I like the basic premise behind Gilroy’s story, i.e., that corporations are as secretive and paranoid as governments, and, in general, the way it’s executed. My only problem is that there’s so much gaming and faking and trickery going on between Ray and Claire and their employers — and between Ray and Claire themselves — that it’s hard to feel a connection to them. It’s made clear right away that they’re essentially con artists, both romantically and professionally — and how can we sympathize with the emotions of someone who might be faking those emotions as part of a ruse? It’s one thing for a character to keep everyone else at arm’s length; must they push us away, too? When the film reveals its satisfying (and funny) final surprises, it would be nice to feel their impact as much as Ray and Claire do.

B (2 hrs., 5 min.; PG-13, a little profanity, a little sexuality, some mild violence.)