On May 23, as President Donald Trump flew from Tel Aviv to Rome, one of his advisers boasted to reporters accompanying Trump on Air Force One of the success of his visit to Saudi Arabia. “Donald Trump united the entire Muslim world in a way that it really hasn’t been in many years,” the adviser said, with no hint of irony at such a grandiose claim. Trump was basking in the glow of the grand reception he got in the kingdom—and he used his visit to firmly side with Saudi Arabia and other Sunni Arab states in their conflict against Iran.

Less than two weeks later, the Trump aide’s bombastic claim had unraveled. In the early hours of June 5, Saudi Arabia and four of its Arab allies suddenly cut off all diplomatic and economic relations with Qatar, a tiny emirate in the Persian Gulf that is rich in natural gas. The Saudis and their allies accused Qatar of financing terrorism; supporting Islamist groups like the Muslim Brotherhood and Hamas; and undermining Arab efforts to isolate Iran. They also imposed a partial blockade, sealing off Qatar’s only land border (with Saudi Arabia) and restricting air and sea travel to and from the peninsula.

The Saudis, along with allies Egypt and the United Arab Emirates, were clearly emboldened by Trump’s unequivocal support. Instead of uniting the Muslim world, or even the smaller realm of Sunni Arab monarchies, his visit has thrown regional alliances into disarray. The Saudis’ dream of a united front against their rival Iran is in jeopardy, as even some of their allies worry about a Saudi-fomented coup or war to bring Qatar to heel.

In a speech before dozens of leaders from across the Muslim world who had gathered in Riyadh, the Saudi capital, on May 21, Trump condemned Iran for stoking “the fires of sectarian conflict and terror,” and he urged fellow Muslim states to isolate Tehran. “Until the Iranian regime is willing to be a partner for peace,” Trump said, “all nations of conscience must work together to isolate Iran, deny it funding for terrorism, and pray for the day when the Iranian people have the just and righteous government they deserve.”

Trump made no mention of Saudi Arabia’s destabilizing actions in the Middle East, especially its war in Yemen, which has killed nearly 10,000 Yemenis and left 6.8 million people—a quarter of Yemen’s population—on the brink of famine. By blatantly taking sides and singling out Iran for supporting terrorism and instigating sectarianism, Trump will only exacerbate the proxy war between Iran and Saudi Arabia and worsen sectarian conflict in the region. It’s clear that Trump has waded into complex religious and political dynamics he doesn’t grasp.

Since he took office, Trump and his top advisers have shifted US rhetoric toward more explicit support for Saudi Arabia and constant criticism of Iran. The transformation was complete during Trump’s visit to the kingdom, which he chose as the first stop on his maiden overseas trip as president. In his speech to nearly 50 Arab and Muslim leaders, Trump reinforced the comments of his host, King Salman. “The Iranian regime represents the tip of the spear of global terrorism,” the king said in his effusive speech introducing Trump.

Like his Saudi hosts, Trump framed the problems of the Middle East as solely due to Iranian belligerence and terrorism by Islamist extremist groups. But Saudi Arabia, along with its allies the United Arab Emirates and Kuwait, have themselves allowed wealthy individuals to finance militants in Syria and Iraq, helping fuel the civil wars there. Notably, Trump toned down his harsh rhetoric against Islam and urged the leaders to “drive out” Islamist militants and jihadists from their societies. But he failed to address one of the root causes of extremism: the repressive policies of the very monarchs, autocrats, and strongmen who assembled in an opulent hall with a gilded ceiling and plush armchairs to hear Trump’s remarks. And he did not mention Iran’s presidential election two days earlier, in which nearly 45 million Iranians voted and overwhelmingly reelected the moderate Hassan Rouhani as president.

Instead, Trump played up the danger of the Iranian bogeyman. “From Lebanon to Iraq to Yemen, Iran funds, arms, and trains terrorists, militias, and other extremist groups that spread destruction and chaos across the region,” Trump said, echoing the harsh comments of the Saudi king. “For decades, Iran has fueled the fires of sectarian conflict and terror. It is a government that speaks openly of mass murder, vowing the destruction of Israel, death to America, and ruin for many leaders and nations in this room.”

Iran does meddle throughout the region, and it has caused enormous bloodshed, most recently through its support for the brutal regime of Syrian President Bashar al-Assad, which has killed hundreds of thousands of its own people. After a popular uprising erupted in Syria in 2011, Assad clung to power thanks to assistance from Iran and its Shiite allies in Lebanon and Iraq, especially Hezbollah, Lebanon’s most powerful militia and political party. But most Islamist extremist groups in the Middle East—Al Qaeda and its various offshoots, including the Islamic State—are Sunni, not Shiite. And these groups are much closer in theology and doctrine to the Wahhabi strain of Islam prevalent in Saudi Arabia than the revolutionary Shiism of Iran. Many Sunni jihadists regard Shiites as infidels who must be killed. During Iraq’s civil war, Sunni extremists led by Al Qaeda in Iraq, the predecessor of ISIS, relentlessly targeted Shiite civilians with suicide bombings and other attacks. (ISIS has also carried out attacks in several Sunni-majority countries, including Saudi Arabia, Egypt, Libya, Turkey, Afghanistan, and Pakistan.) On June 7, ISIS fighters staged two attacks in Tehran, killing at least 17 people and wounding dozens. It was the first time that ISIS had struck inside Iran.

These distinctions between Sunni and Shiite extremism don’t matter to Trump, and he’s likely ignorant of them entirely. During the presidential campaign, Trump often criticized the Obama administration for being too “soft” on Iran and for allowing it to gain influence throughout the Middle East. Trump also promised to “rip up” the July 2015 agreement that Iran signed with the United States and five other world powers to limit Tehran’s nuclear program in exchange for the lifting of international sanctions. (“My number-one priority is to dismantle the disastrous deal with Iran,” he told the pro-Israel lobbying group AIPAC in March 2016.)

In reality, Trump could not unilaterally dismantle the deal with Iran, but his rhetoric resonated with the Saudi leadership. The Saudis believe that Barack Obama’s administration had abandoned its traditional allies in the Arab world, especially the kingdom and other Sunni Arab states, in favor of a pivot toward Iran. The Saudis were particularly dismayed after Obama invested considerable political capital to negotiate the nuclear deal, which allowed Iran to reenter the global financial system, increase its oil exports, and potentially access about $50 billion in frozen assets.

Trump’s tough talk fits well with a newly aggressive Saudi Arabia. For decades, the kingdom pursued a largely behind-the-scenes foreign policy that benefited from economic expansion fueled by booming oil prices. Saudi leaders exerted their power by funding proxies and friendly Arab and Muslim politicians—and the kingdom largely avoided direct military intervention. But today, even as Saudi Arabia struggles economically because of the global fall in oil prices, the new King Salman and his advisers are becoming more aggressive militarily, most notably by launching the war in Yemen two months after Salman rose to power in January 2015. Aside from Obama’s perceived turn toward Iran, the Saudi royals also loathed him for his rhetorical support of the 2011 popular uprisings in the Arab world and his occasional admonishments of regional leaders on the need for democratic reforms and respect for human rights.

On that score, Trump dropped any pretense of pressuring US allies to tolerate dissent and open up political space. “We are adopting a principled realism,” he said. “Our partnerships will advance security through stability, not through radical disruption.” He added that “wherever possible, we will seek gradual reforms, not sudden intervention. We must seek partners, not perfection.” This is straight out of the Saudi playbook: The ruling House of Saud often promises gradual change—especially on demands for social reform and greater freedoms, including women’s rights—but then it doesn’t follow through. (Saudi Arabia, for example, is the only country in the world that forbids women from driving, and its leaders insist that society isn’t ready for that to change.) Trump’s comments were music to the ears of every autocrat sitting in that grand hall in Riyadh.

Aside from his virtually unqualified rhetorical support for Saudi Arabia, Trump announced a package of weapons sales to the kingdom that will total nearly $110 billion over 10 years. Trump and his top aides—especially his son-in-law and senior adviser Jared Kushner, who took a lead role in negotiating parts of the agreement—were quick to claim credit for a massive arms deal that would boost the US economy. But many of the weapons that the Saudis want to buy—including dozens of advanced F-15 fighter jets, Apache attack helicopters, Patriot missile-defense systems, thousands of bombs and other munitions, and hundreds of armored vehicles—were already approved by the Obama administration. From 2009 to 2016, Obama authorized a record $115 billion in military sales to Saudi Arabia, far more than any previous administration. (Of that total, US and Saudi officials inked formal deals worth about $58 billion, and Washington delivered $14 billion worth of weaponry from 2009 to 2015.)

With such a large influx of US weapons and Trump’s uncritical support, the emboldened Saudi leadership now sees itself as perfectly aligned with Washington against Iran—and even against a longtime US ally like Qatar, which, in the Saudi view, has been too cozy with Iran.

Iran and Saudi Arabia have been fighting a cold war since the 1979 Islamic Revolution in Iran—and their struggle has only intensified over the past decade. While the conflict is partly rooted in the Sunni-Shiite schism within Islam, it is mainly a struggle for political dominance of the Middle East between Shiite-led Iran and Sunni-led Saudi Arabia. This series of proxy battles—in Iraq, Syria, Yemen, Lebanon, and Bahrain—has shaped the Middle East since the Bush administration invaded Iraq in 2003.

The House of Saud rests its legitimacy—and its claim of leadership over the wider Muslim world—on the fact that the kingdom is the home of Islam’s two holiest cities, Mecca and Medina, where the religion was founded. Like his predecessors, King Salman has adopted the title of “Custodian of the Two Holy Mosques,” a reminder of his rule over Islam’s most sacred shrines. This gives the Sauds great convening power in the Muslim world. Because the Saudi regime controls access to the annual hajj—the pilgrimage to Mecca that every pious Muslim must perform at least once in a lifetime—Salman was able to call so many Muslim leaders to Saudi Arabia for Trump’s speech on relatively short notice. These leaders want to stay in the king’s good graces, both to maintain access to hajj visas for their citizens and also because the Sauds dole out money to favored allies.

The Sauds, and the Wahhabi clerics who support them, construe political legitimacy on the Islamic concept that Muslims owe obedience to their ruler, as long as he can properly apply Islamic law. This view does not tolerate public dissent or demands for reform. The Sauds also want to associate Islam with its original Arab identity, even though Arabs have been a minority within the religion for centuries. Far more Muslims now live in Asia than in the Arab world—and states like Indonesia and Malaysia offer a more tolerant conception of the faith than the Saudis.

While the Saud dynasty views itself as the rightful leader of the Muslim world, Iran has challenged that leadership for decades. Iran’s 1979 Islamic Revolution brought to power a group of clerics led by Ayatollah Ruhollah Khomeini, who vowed to export his rebellion throughout the Muslim world—starting with Saudi Arabia and other Sunni Arab states. Although Saudi Arabia has a Sunni majority, its rulers fear Iran’s potential influence over a sizable and sometimes restive Shiite minority, which is concentrated in the Eastern Province, where most of the kingdom’s oil reserves lie. When Iraqi dictator Saddam Hussein invaded Iran in 1980, Saudi Arabia and other Sunni Arab states provided money and support, hoping that Saddam would weaken Iran and force Khomeini and the clerics out of power. (The United States and most Western powers also supported Iraq, selling it weapons and providing intelligence support.) But the Iran-Iraq War dragged on for eight years, killing about 1 million people and crippling both countries.

The Saudi-Iranian rivalry continued throughout the 1980s, easing slightly in the 1990s after Saddam invaded neighboring Kuwait and threatened to march into Saudi Arabia. Washington sent half a million troops to the kingdom, using it as a base from which to drive the Iraqis out of Kuwait in 1991. The Saudi-Iranian relationship thawed for nearly decade. But after the US invasion of Iraq in 2003, the traditional centers of power in the Arab world—Egypt, Saudi Arabia, and other Gulf states—became more nervous about Iran’s growing influence: its nuclear ambitions, its sway over the fledgling Iraqi government, its support for Islamist groups like Hamas and Hezbollah, and its alliance with Assad’s regime in Syria.

The conflict with Iran intensified after the Arab uprisings of 2011 when the House of Saud tried to choke off revolutionary momentum in the region. Saudi leaders tended to view all Shiite politicians and factions in the Muslim world as agents of Iran—and they attached an Iranian connection, whether real or imagined, to virtually any regional security issue. After the wave of popular protests forced out dictators in Tunisia, Egypt, Libya, and eventually Yemen, the Sauds were worried about the revolts spreading to the kingdom.

Aside from their anger toward Iran, the Sauds were also enraged by Qatar’s support for the revolutions in Tunisia, Libya, and especially Egypt, where Qatar became a primary backer of the Muslim Brotherhood, which in 2012 won the first free elections in Egypt’s modern history. (Saudi Arabia and the United Arab Emirates later backed an Egyptian military coup, in July 2013, against the government of President Mohamed Morsi, a Brotherhood leader.) The Sauds were already irritated at Qatar for pursuing an independent foreign policy and trying to increase its influence after the regional turmoil unleashed by the US invasion of Iraq. And, like other Arab monarchs and autocrats, the Sauds disdained Qatar’s Al Jazeera satellite network, which was critical of the monarchies and supported the uprisings in 2011.

The House of Saud became especially nervous when the Arab revolutions spread to Bahrain, a Shiite-majority country ruled by a Sunni monarchy only 16 miles from Saudi Arabia’s heavily Shiite Eastern Province. The Sauds accused Iran of supporting the Bahrain uprising and in March 2001 sent more than 1,000 troops to help crush the pro-democracy movement there. Saudi Arabia also steered the six-member Gulf Cooperation Council, which was created in 1981 partly to counter Iran, to begin discussions on offering membership to Jordan and Morocco. The two non-Gulf, non-oil-producing Sunni monarchies were invited to join in April 2014, although the process has since stalled. It’s all part of the Saudi-led effort to build a stronger bulwark against Iran.

In January 2015, King Abdullah died, after 20 years in power, and was succeeded by his brother Salman, the 79-year-old crown prince who had served as the longtime governor of Riyadh. Instead of relying on US military intervention and battling Iran through proxies and checkbook diplomacy, as his predecessor had done, the new king and his advisers quickly pursued a more aggressive foreign policy: He launched a war against Houthi rebels in Yemen after only two months in power. Salman also appointed his then-29-year-old son as defense minister (and deputy crown prince, making him second-in-line to the throne, after Crown Prince Mohammed bin Nayef) to oversee the Yemen campaign.

Yemen, which is rapidly becoming one of the bloodier arenas in the Saudi-Iranian proxy war, is a complex conflict with a shifting set of alliances. The Saudis and their Sunni Arab partners want to restore Yemeni President Abdu Rabbu Mansour Hadi, a Sunni, to power. The Houthis, who belong to a sect of Shiite Islam called Zaydis, are allied with former President Ali Abdullah Saleh, a longtime dictator who was ousted from power after the Arab uprisings spread to Yemen. Once a Saudi client, Saleh was replaced by Hadi in 2012 under a deal brokered by Riyadh. The Houthis are also allies of Iran, but while the Saudis are quick to label them as Iranian proxies, it’s unclear how much support they actually receive from Tehran. (By comparison, Iran is far more heavily invested in Syria, where it has sent billions of dollars in aid and thousands of troops and Shiite volunteers to fight alongside Assad’s regime.)

After two years, Saudi Arabia is bogged down in the Yemen conflict, which by some estimates costs up to $200 million a day. Despite intensive air strikes and a naval blockade, the Saudis and their allies still have not been able to dislodge the Houthis from Yemen’s capital, Sanaa. But the House of Saud—and especially Mohammed bin Salman, the brash 31-year-old deputy crown prince, who has amassed tremendous power under his father’s reign—is reluctant to abandon the war. In the regional proxy conflict, the Saudis view a peace deal with the Houthis as a victory for Iran.

Since he took office, Trump has changed his position on many foreign-policy questions. But he’s been consistent on one topic: He and his advisers consider Iran the greatest threat to US interests in the Middle East, and the world’s biggest state sponsor of terrorism. And Trump has surrounded himself with senior officials who view Iran in the same light, including Defense Secretary James Mattis and National Security Adviser H.R. McMaster. Both men commanded US troops in Iraq, and both fought Iranian proxies.

Trump’s confrontation with Iran began in his early days in office. On January 29, Iran tested a medium-range ballistic missile—a trial that Iranian officials insisted did not violate a United Nations Security Council resolution that calls on Tehran to refrain from testing weapons that can carry nuclear warheads. But Trump and his advisers jumped on the episode to show that they will take a more aggressive approach. On February 1, Trump’s then–National Security Adviser Michael Flynn declared, “As of today, we are officially putting Iran on notice.” Two days later, the administration imposed new sanctions on 25 people and entities involved in developing Iran’s missile program or helping to support groups that Washington has designated as terrorist organizations. Hours before imposing the sanctions, Trump fired off a series of provocative tweets, including one that warned: “Iran is playing with fire—they don’t appreciate how ‘kind’ President Obama was to them. Not me!”

These comments set the framework for the pro-Saudi tilt in US policy and aggressive posture toward Iran. But despite Trump’s tough rhetoric, his administration needs Iran’s cooperation in the military campaign against ISIS, in both Syria and Iraq. Facing ground offensives by local forces backed by US air strikes, the group has suffered significant defeats over the past year, especially in Iraq. ISIS is on the verge of being completely expelled from the northern city of Mosul by Iraqi forces. And in Syria, US-allied rebels have besieged the eastern city of Raqqa, the capital of ISIS’s self-proclaimed caliphate.

Iran has a vested interest in fighting ISIS, especially because of the danger it poses to Tehran’s allies in Iraq. After the US invasion ousted Saddam Hussein from power, the Bush administration helped install a Shiite government for the first time in Iraq’s modern history. As US troops got bogged down in fighting an insurgency and containing a civil war, Iran extended its influence over all of Iraq’s major Shiite factions. (Iran helped prolong the civil war by arming and training numerous Shiite militias that targeted American troops and Iraq’s Sunni community.) For the Iranian regime, Iraq provides strategic depth against Saudi Arabia and other Sunni Arab states. Tehran also wants to ensure that Iraq does not pose an existential threat to Iranian interests, as Saddam did when he invaded Iran in 1980.

After ISIS militants captured large swaths of northern Iraq in June 2014, including Mosul, Iran helped train and equip tens of thousands of volunteers who joined largely Shiite militias that worked alongside the Iraqi security forces. With a weakened Iraqi military, the militias proved crucial in stopping the Sunni jihadists’ initial advance in 2014. Today, some Iraqi military units work closely with US commanders, especially in the campaign to oust ISIS from Mosul. But Iran still exerts influence over the Popular Mobilization Units, the coalition of militias that is now under the Iraqi government’s control.

On April 18, the State Department certified to Congress that Iran was complying with its obligations under the 2015 nuclear agreement. But the next day, Secretary of State Rex Tillerson lashed out at Tehran in a hastily organized press conference, claiming that the nuclear deal “fails to achieve the objective of a non-nuclear Iran.” He then listed Iran’s destabilizing activities in the Middle East and the threat they pose to US interests. He said Trump’s National Security Council would conduct a 90-day review of the nuclear deal, after which it could decide to back away from the agreement or to impose new sanctions on Iran. “The Trump administration has no intention of passing the buck to a future administration on Iran,” Tillerson said. “The evidence is clear. Iran’s provocative actions threaten the United States, the region, and the world.”

These threats foreshadowed Trump’s speech in Riyadh—and the administration’s decision to explicitly take Saudi Arabia’s side in an unpredictable and destructive proxy war with Iran. The newly emboldened Saudi leadership has shown—with its war in Yemen and, more recently, its campaign to isolate Qatar—that it can miscalculate and overreach. Without a US administration willing to restrain Saudi ambitions, the proxy war will get worse.