Getting your Trinity Audio player ready...

So far, most movies about the post-9/11 war on terror have been somber, sensitive pieces, even at their most intense and horrific moments.

Not the case with “The Kingdom.” Very loosely inspired by the Khobar Towers bombing in 1996, this fictionalized story about FBI agents investigating an attack on an American workers’ compound in Riyadh, Saudi Arabia, certainly takes geopolitics and terrorist violence seriously.

But it’s also a visceral action movie that isn’t afraid to have a little fun with an extreme fish-out-of-water cop film concept.

Jamie Foxx plays the leader of the American investigators (Jennifer Garner, Chris Cooper and Jason Bateman are the rest of his team).

Not surprisingly, they find the restrictions of the devoutly Muslim kingdom frustrating and absurd, breaking the ever-present tension with gallows humor. The target of most of their jokes and complaints is their by-the-book Saudi police liaison/minder, played by Israeli-Arab actor Ashraf Barhom.

Eventually, the two top cops bond. But mainly they’ve got each other’s backs as the investigation heats up, culminating in a chaotic kidnapping/car chase/urban shootout to rival any fantasy blockbuster’s big-money sequence.

“[Director] Peter [Berg] wanted to catch things on the fly and flash,” Foxx says, “to keep the movie organic and quick.

“But I think the beauty in this movie is the relationship between Ashraf’s and my characters, how they share human things. You know, whenever you watch TV, it’s propaganda, they’re the bad guys, and over there they may be saying that Americans are the bad guys. But … I think it’s beautiful how Peter shows the Muslims in their natural life; eating, playing with their kids. At the same time, it’s entertaining.”

Foxx got a first-hand taste of American-Arab cooperation when he spent 10 days shooting on location in the United Arab Emirates capital of Abu Dhabi. “Kingdom” was the first Hollywood movie to film in the oil-rich sheikhdom, and Foxx says it was a blast.

“I didn’t experience any anti-Americanism at all,” the Oscar-winning actor says. “They have satellite TV, watch a lot of ‘Access Hollywood’; they were definitely into Western culture and at the same time peacefully enjoying theirs.”

Setting up the film wasn’t easy, though. Extensive negotiations and bureaucratic arm-wrestling were required to bring in weapons, FBI uniforms and actors with Israeli passports, who are essentially banned from entering most Arab nations.

“It was thrilling, but scary,” director Peter Berg says.

“You’re in the middle of a Muslim city and there was a war between Israel and Lebanon going on at the time. It’s disorienting; the culture is so different. It takes a while to look someone in the eye before they smile. But I made great friends with many Arabs while I was there, which reinforced my belief that the great majority of Muslims are not violent religious extremists.”