Secretary of Defense James Mattis and Secretary of State Rex Tillerson at the U.S. State Department in Washington, D.C., June 21. DoD photo by U.S. Army Sgt. Amber I. Smith/Flickr/Creative Commons.

On March 25, 2011, a Qatar Air Force Mirage 2000-5, took off from Souda Air Base, in Crete, to help enforce a no-fly zone protecting rebels being attacked by Libyan strongman Muammar Qaddafi. Qatar was the first Persian Gulf nation to help the U.S. in the conflict.

Qatari operations were more than symbolic. The Qatari military trained rebel units, shipped them weapons, accompanied their fighting units into battle, served as a link between rebel commanders and NATO, tutored their military commanders, integrated disparate rebel units into a unified force and led them in the final assault on Qaddafi’s compound in Tripoli.“We never had to hold their hand,” a retired senior U.S. military officer says. “They knew what they were doing.” Put simply, while the U.S. was leading from behind in Libya, the Qataris were walking point.

The Qatar intervention has not been forgotten at the Pentagon and is one of the reasons why Defense Secretary James Mattis has worked so diligently to patch up the falling out between them and the coalition of Saudi-led countries (including the UAE, Bahrain and Egypt), that have isolated and blockaded the nation. In fact, Mattis was stunned by the Saudi move. “His first reaction was shock, but his second was disbelief,” a senior military officer says. “He thought the Saudis had picked an unnecessary fight, and just when the administration thought they’d gotten everyone in the Gulf on the same page in forming a common front against Iran.”

At the time of the Saudi announcement, Mattis was in Sydney with Secretary of State Rex Tillerson to dampen concerns about the Trump administration’s withdrawal from the Trans-Pacific Partnership and the Paris climate accords. The two glad-handed Australian officials and issued a reassuring pronouncement on U.S. intentions during a June 5 press briefing with that nation’s foreign and defense ministers. When the burgeoning split between the Saudis and Qataris was mentioned, Tillerson described it as no more than one of “a growing list or irritants in the region” that would not impair “the unified fight against terrorism …”

But while Tillerson’s answer was meant to soothe concerns over the crisis, behind the scenes he and Mattis were scrambling to undo the damage caused by Saudi action. The two huddled in Sydney and decided that Tillerson would take the lead in trying to resolve the falling out. Which is why, three days after the Sydney press conference, Tillerson called on Saudi Arabia, the UAE, Bahrain and Egypt to ease their anti-Qatar blockade and announced that the U.S. supported a Kuwaiti-led mediation effort. The problem for Tillerson was that his statement was contradicted by Donald Trump who, during a Rose Garden appearance on the same day, castigated Qatar, saying the emirate “has historically been a funder of terrorism at a very high level.”

A close associate of the secretary of state says that Tillerson was not only “blind-sided by the Trump statement,” but “absolutely enraged that the White House and State Department weren’t on the same page.” Tillerson’s aides, I was told, were convinced that the true author of Trump’s statement was U.A.E. ambassador Yousef Al Otaiba, a close friend of Trump son-in-law Jared Kushner. “Rex put two-and-two together,” his close associate says, “and concluded that this absolutely vacuous kid was running a second foreign policy out of the White House family quarters. Otaiba weighed in with Jared and Jared weighed in with Trump. What a mess.” The Trump statement was nearly the last straw for Tillerson, this close associate explains: “Rex is just exhausted. He can’t get any of his appointments approved and is running around the world cleaning up after a president whose primary foreign policy adviser is a 36-year-old amateur.”

Worse yet, at least from Tillerson’s point of view, a White House official explained the difference between the two statements by telling the press to ignore the secretary of state. “Tillerson may initially have had a view,” a White House official told the Washington Post, “then the president has his view, and obviously the president’s view prevails.”

Or maybe not. While Trump’s June 9 statement signaled that the U.S. was tilting towards the Saudis and the UAE, Tillerson and Mattis have been tilting towards Qatar. And for good reason. “Every time we’ve asked the Qataris for something they’ve said ‘yes,’ which isn’t true for the Saudis,” the retired senior U.S. military officer with whom I spoke says. “It really started with the help the Qataris gave us in Libya, but it goes well beyond that. They’ve been absolutely first rate on ISIS. The Saudis, on the other hand, have been nothing but trouble – in Yemen, especially. Yemen has been a disaster, a stain. And now there’s this.”

That view has been reflected by both Mattis and Tillerson. Six days after Trump’s statement, Mattis met with Qatari Defense Minister Khalid al-Attiyah to sign an agreement shipping 36 F-15 fighters to the Gulf nation. The $12 billion sale had been in the works for years, so Pentagon officials were able to claim that it had not been fast-tracked by Tillerson, whose department oversees arms transactions. But the Mattis announcement seemed suspiciously well-timed to signal Mattis’ and Tillerson’s views.

On the same day that Mattis was announcing the Qatar arms agreement, Tillerson told the House Foreign Affairs Committee that it would be a mistake to classify the Muslim Brotherhood as a terrorist group, one of the primary reasons that the anti-Qatar coalition gave for isolating their Gulf neighbor. “There are elements of the Muslim Brotherhood that have become parts of government,” Tillerson said, naming Turkey and Bahrain as having brotherhood members in their parliaments. Those “elements,” Tillerson added, have renounced violence and terrorism. “So, in designating the Brotherhood in its totality as a terrorist organization . . . I think you can appreciate the complexities this enters into our relations with [governments in the region].”

But the single most important reason for the Qatar tilt is obvious to anyone who knows how to read a map. The U.S. leases the al-Udeid Air Base, southwest of Doha, which is home to the Air Force’s 379th Air Expeditionary Wing. The U.S. (and the Qataris), not only mount fighter-bombers from al-Udeid against ISIS units in Iraq and Syria, the base serves as the first line of defense against Iranian encroachments in the region. Even more crucially, al-Udeid not only protects America’s Persian Gulf allies, it protects Israel – and would be a launching point for U.S. aircraft against Iran were Israel to be attacked by the Islamic Republic.

More crucially, particularly from Mattis’s point-of-view, the Saudi-Qatar feud not only shattered the anti-Iran coalition the administration cobbled together during the president’s trip to Riyadh, it redrew the geopolitical map of the Middle East. In the wake of the Saudi-Qatar falling out, Turkey pledged its support for Qatar (and deployed troops to a Qatari military base to guard Qatar’s sovereignty), while Iran took steps to help ease the Saudi-imposed blockade.

“The Saudis and Emiratis have told us repeatedly that they want to weaken Iran, but they’ve actually empowered them,” a senior Pentagon consultant who works on the Middle East told me. The Saudi actions, this official went on to explain, have backfired. Instead of intimidating the Qataris, the Saudis have “thrown them into the arms of the Iranians.” The result is an uneasy, but emerging Turkish-Qatari-Iranian alliance backed by Russia. “This isn’t just some kind of Gulfie dust-up, where we can go out and hold everyone’s hands,” this Pentagon consultant says. “The Saudis have handed the Iranians a gift and we’re on the outside looking in.”

The official then shook his head. “Listen, I can certainly understand where Mattis and Tillerson are coming from. I mean, with friends like these, who needs enemies.”

Mark Perry is a foreign policy analyst and the author of The Most Dangerous Man in America: The Making of Douglas MacArthur. His next book, The Pentagon’s Wars, will be released in October. He tweets @markperrydc