WATCH: Inside the awkward US-Saudi alliance against ISIS

Saudi Arabia fight ISIS

Saudi Arabia's representative Abdullah Al Othman attends the opening session of the Global Coalition Against ISIS Communication Working Group conference in Kuwait on April 25, 2016.

Stephanie McGehee/Reuters

When ISIS began setting up schools to teach the next generation of jihadis, the terror group didn’t have to start from scratch on its curricula.

Instead, its members took to the internet, downloading PDFs of textbooks that had been posted online by Saudi Arabia’s ministry of education and that preached hatred for anyone who’s not a follower of the ultra-conservative Wahhabi branch of Islam.

The Saudis have since revised some of their textbooks, but it was an awkward moment nonetheless in the relationship between the United States and one of its closest allies in the Middle East — one that’s explored as part of a new FRONTLINE documentary about the complicated, US-led fight against ISIS.

Premiering Tuesday at 9 p.m. EST/8 p.m. CST on PBS stations and online, "Confronting ISIS" is a revealing look inside the effort to defeat the terror group from producers Martin Smith and Linda Hirsch.

In this two-hour special, Smith, who has been documenting conflicts in the Middle East for FRONTLINE for 15 years, travels to five countries with key roles in the anti-ISIS fight — Iraq, Jordan, Saudi Arabia, Syria and Turkey — and sits down for candid interviews with policy makers inside Washington, DC’s corridors of power.

What emerges is not just the story of deep tensions between the White House and the Pentagon over how best to combat ISIS, but a comprehensive look at a fundamental problem with the fight: Nearly every step of the way, US priorities have clashed with those of its regional allies in the Middle East.

Allies including Saudi Arabia, the birthplace of Wahhabism, an extremely strict branch of Islam that has been accused of sanctioning violence against Christians, Jews and all non-Wahhabi Muslims. 

Smith spent 10 days filming in Saudi Arabia earlier this year. In the above excerpt from "Confronting ISIS," he goes inside a Wahhabi mosque and conducts a rare interview with the Grand Mufti, Saudi Arabia’s highest religious authority.

“Our Muslim community rejects terrorism in all its forms and doesn’t cooperate with it,” he tells Smith, denying any connection between Wahhabis of Saudi Arabia and terrorism.

Other Saudi officials tell Smith they’re working on counter-messaging against extremism. As seen in the above clip, one Saudi TV show, “Selfie,” mocks ISIS through comedy. Whether those attempts are working is an open question: ISIS has drawn more young men from Saudi Arabia than any other Gulf state.

But ultimately, as "Confronting ISIS" explores, counter-messaging against ISIS isn’t Saudi Arabia’s top priority. Instead, it is the kingdom’s long struggle against its arch-rival, Iran.

It’s just one instance of competing priorities between the US and its allies in the Middle East that Smith explores in Tuesday night's film — from how to deal with Bashar al-Assad in Syria, to the Kurdish-Turkish conflict, to the war in Yemen.

Taken together, these clashing agendas paint a complex scenario of why President Barack Obama’s goal to “degrade and ultimately destroy” ISIS is taking so long.

“The challenge, of course, we’ve had in the Middle East … they all are concerned about [ISIS]. There is no question about that. But they don’t always rank … their concerns in the same order that we do,” Colin Kahl, deputy assistant to the president, tells Smith.

Confronting ISIS premieres Tues., Oct. 11 at 9 p.m. EST/8 p.m. CST on PBS stations and online. Check your local PBS station for air times.

This post originally ran on FRONTLINE.