The opening scene of “Kandahar” depicts a familiar situation for a Gerard Butler action movie. Butler plays a spy named Tom Harris, operating undercover in Iran as a telecommunications engineer, and a group of Iran Revolutionary Guards suspect he’s a spy.

In most action movies, the question boils down to: Does he shoot his way out or punch his way out? Instead, Tom pulls out a cellphone and shows the guards how much better the wi-fi is for watching soccer.

The punching and the shooting will come later — boy, will they ever. But the fact that “Kandahar” is willing to be quiet in its opening half hour is a good sign, letting first-time screenwriter Mitchell LaFortune lay some groundwork about the volatile politics of the Middle East and some backstory about his characters.

Kandahar

Gerard Butler plays a spy trying to escape Afghanistan in “Kandahar.”

Reteaming Butler with director Ric Roman Waugh (“Angel Has Fallen,” “Greenland”), “Kandahar” reminded me of a thriller you’d pull off the rack in an airport shop while waiting for a delayed flight. But it’s a good story that knows its gunfights will be more engrossing if we know and care a little about the people pulling the triggers.

“Kandahar” opens Friday in Madison theaters at AMC Fitchburg 18, Marcus Point and Marcus Palace.

In fact, Tom was not in Iran to fix the wi-fi, but to sabotage a secret nuclear facility. The mission seems to be a success, and Tom wants to head home to London for his daughter’s graduation.

But he’s convinced by his handler Roman (Travis Fimmel) to take on one more mission to sabotage a runway near the Iran-Afghanistan border. Roman sets Tom up with an interpreter, Mohammad (Navid Negahban), who escaped to the United States after the fall of Kabul, but has returned to search for his missing sister-in-law.

But after Tom lands in Afghanistan, Iran intelligence officials uncover Tom’s real identity. Pretty soon Tom and Mohammed are racing to escape the country, with Taliban, Iranian and Pakistani agents all closing in.

The clock is ticking — in 30 hours a British plane is taking off from an abandoned military base in Kandahar, 400 miles away. (The setup is surprisingly similar to another recent action movie, “Guy Ritchie’s The Covenant,” about a U.S. Marine and his translator bonding while on the run in Afghanistan.)

Once the action gets rolling, Waugh stages some expert sequences, including a car chase in the middle of a traffic-clogged downtown and a stunning nighttime duel with a helicopter shot through night-vision goggles.

“Kandahar” was the first major film to be shot in Saudi Arabia since “Lawrence of Arabia,” and Waugh effectively uses stunning desert landscapes and urban locations, adding geographical and cultural textures that would be absent in more generic thrillers set in the region.

Butler and Negahban have a good rapport onscreen as a couple of world-weary fighters trying to help each other survive. The bond they develop feels earned in a way a similar relationship in “The Covenant” felt underdeveloped.

The supporting characters are more vividly drawn. Roman has converted to Islam during his time in the Middle East, while the Pakistani agent (Ali Fazal of “Victoria and Abdul”) is a vaping, trap music-loving playboy who zips around on a dirt bike. In another movie, he’d be the hero.

And at this point in his career, Butler is like an old battered suitcase of an action hero — banged-up and rough around the edges, but dependable and durable. “Kandahar” plays to his world-weary strengths.