At present Riyadh is challenged by three simultaneous existential threats. Managing through any one of these would be difficult for most leaders. Confronting all three of them together would test even statesmen with decades of experience.

An all-powerful leader is upset to hear from his most trusted advisors that a fellow countryman living abroad has become a dangerous opposition leader. He orders him to be killed, sending an unmistakable message to anyone who might challenge his rule. But the murder backfires horribly when it becomes public. Instead, the shocking act now convinces others to view this leader, once hailed as a harbinger of necessary reforms, as a threat to regional stability.

Is this the story of Saudi Arabia’s Crown Prince Mohammed bin Salman and the murder of Jamal Khashoggi? No, this happened over two hundred years ago, when Napoleon ordered the assassination of Louis Antoine de Bourbon, duc d’Enghien. Other European monarchs were aghast. “After the murder of the duc even the most partial ceased to regard [Napoleon] as a hero,” as Tolstoy had a Russian character explain in War and Peace. Soon thereafter Russia and Austria joined Britain in the war against France. Back in Paris there was only one conclusion to make: c’est pire qu'un crime, c’est une faute—it was worse than a crime; it was a mistake.

And now, after weeks of denials and obfuscation, Saudi foreign minister Adel bin Ahmed al-Jubeir has said that Khashoggi’s murder was a “tremendous mistake.” Unfortunately, there has been no shortage of such mistakes during the relatively short time since Mohammed bin Salman rose to power. And while the Middle East today doesn’t face an imminent risk of their version of the Napoleonic wars, there are many worrisome trends and risky flash points that could end up pushing the region in a far more perilous direction—and directly threaten U.S. interests. For Saudi Arabia’s own sake and ours, therefore, both the crown prince and his father, King Salman, need to learn the right lessons from their self-defeating blunders.

At present Saudi Arabia is challenged by three simultaneous existential threats. Managing through any one of these would be difficult for most leaders. Confronting all three of them together would test even statesmen with decades of experience. Mohammed bin Salman must do so in his early thirties, at the outset of his reign.

The first threat to Saudi Arabia is internal, from the uncertainty that hangs over the unfinished leadership transition. A different branch of the House of Saud has taken charge, demoting or dismissing competing relatives along the way. Any Game of Thrones fan will immediately recognize the potential dangers. Within this leadership transition is also a generational shift that extends beyond the empowerment of a novice prince by his octogenarian father. Leadership is similarly being passed to younger royals across ministries and other power centers. This generational shift is critical since Salman will be the last of the founder’s sons to rule, and history records far more hereditary monarchies that failed to last beyond three generations than those that succeeded. And at the same time decisionmaking is becoming more centralized, breaking from a traditional, consensus-driven model of decisionmaking that promoted unity but was too often slow and indecisive.

Such a transition in leadership processes is required to deal with the second existential threat to the Saudi regime, the desperate need for revolutionary internal reforms. Incrementalism is no longer a plausible strategy. For Saudi Arabia to survive in a recognizable form throughout the lifetime of the next king, reforms must take place across economic, social and religious sectors. While there are important pockets of progress in the country—and certain Saudis are among the world’s top investment minds—the wider combination of economic dysfunction, structural inequality, endemic corruption, educational weakness, cultural stagnation, religious extremism, tribal divisions and a demographic surge means that the society will be inherently fragile for decades to come.

The numbers are sobering. More than half of the Saudi population today is younger than the crown prince. In 1945 when President Franklin Roosevelt met Salman’s father, Abdul Aziz ibn Saud, the still relatively new country of Saudi Arabia had about three million people. Now it has well over thirty million and by 2030 it will have about forty million. Young men are the most dangerous element of any society, and a culture that has so many of them and doesn’t provide them with productive opportunities will gravitate toward religious extremism and other destructive impulses. Thus, demographic realities make reform and modernization essential for Saudi Arabia. The king and crown prince clearly understand this existential threat, as confronting it is at the heart of their Vision 2030 domestic reform agenda. And if the Custodian of the Two Holy Mosques continues to promote a return to a more moderate Islam, then the positive ripple effects will resonate far beyond Saudi Arabia.

The third existential threat is external: Iran. Iran has been aggressively expanding its influence throughout the region, upsetting the delicate balance of power which directly threatens Saudi Arabia. Iran governs through its proxy in Lebanon, has all but won the war in Syria, is the most important external political influence in Iraq, and provides indispensable support to the aggressors in the Yemen civil war, resulting in the world’s worst humanitarian crisis. Iran repeatedly threatens the critical maritime routes that carry about a third of the world’s oil tanker traffic, tried to assassinate the Saudi ambassador in Washington not too long ago, has its proxy the Houthis regularly shoot missiles at Riyadh, and is providing its proxy Hezbollah with precision weaponry designed to directly threaten Israel—and the large number of Americans who reside there.

These three strategic imperatives for Saudi Arabia are clear—and daunting. So much so that Saudi Arabia can’t succeed on its own. It can’t reform its economy without the support of global investors; it can’t defend itself against Iran without the support of the United States. The need to maintain this external support should be at the forefront of every decision by the Saudi leadership. And the United States should certainly support the Saudis in these efforts; a stable, reformed and secure Saudi Arabia would advance U.S. interests across the region and the world.

Unfortunately, many recent Saudi actions have backfired, directly undermining their ability to deal with the most important challenges.

Saudi Arabia felt a real threat from the civil war in Yemen, but it escalated the air war far beyond its own military capabilities. Indeed, few air forces are capable of intelligence-driven precision strikes of moving targets in an urban environment while protecting noncombatants—and the Saudi air force certainly isn’t one of them. The humanitarian consequences have pushed anti-Saudi sentiment in the U.S. Congress above even what occurred in the immediate aftermath of 9/11. The next Congress may cut off U.S. military assistance to the Saudi air campaign as a result.

Saudi Arabia had legitimate concerns about Qatar’s tolerance of terrorists and friendliness toward Iran. But instead of building a diplomatic campaign focused narrowly on those issues which could have garnered support, it led the rest of the Gulf states to impose an especially harsh boycott and put forward demands that included provisions that U.S. State Department officials deemed unviable. As a result, instead of Qatar being isolated it has been able to present itself as the victim of unfair accusations and unreasonable ultimatums. Instead of returning to the Gulf Cooperation Council chastened from the experience, Qatar has strengthened its relationships with Iran and Turkey and begun talks to purchase Russian anti-aircraft weapons, all against Saudi interests.

Saudi Arabia correctly recognized that it would not prosper without fighting corruption. But instead of building airtight cases and openly prosecuting the undeniably guilty, the government locked up hundreds of influential businessmen and secretly used extralegal methods to wrest away their wealth. This is hardly the way to strengthen the rule of law and build an attractive investment climate. Indeed, foreign direct investment has plummeted, and high-profile deals have fizzled. Saudi Arabia has been forced to call off plans for the domestic and international listing of state oil giant Aramco, the most anticipated economic element of Vision 2030.

Saudi Arabia was rightly concerned about Lebanon falling under increasing domination by Hezbollah and its Iranian masters. Unfortunately, its leaders decided to bring the Lebanese prime minister to Riyadh and force him to televise an anti-Hezbollah resignation statement. By the end of the month, however, the prime minister was back in office and, in a stunning display of hypocrisy, Hezbollah was able to portray themselves as the guarantors of Lebanese independence from foreign influence.

Professional soccer teams that score so many own goals are relegated to a lower league. As it happens, earlier this year that lower league in Saudi Arabia was renamed to honor Prince Mohammad bin Salman.

And now the world has learned that Saudi Arabian agents killed Jamal Khashoggi—brutally and unjustly. The royal family is desperately working to protect the crown prince from the repercussions of unwise decisions. Once again, the biggest beneficiary of this act is Iran, which is quietly enjoying the chaos. Saudi Arabia’s relationship with the United States, something long understood by Saudi leaders to be essential for their survival, may be at its nadir. Foreign investors are cancelling their visits and putting deals on hold. The Saudi government’s credibility has taken a tremendous hit, not least of which with American officials who believe they were personally lied to. The timing for all of this is particularly problematic, just before President Donald Trump had planned to increase the pressure on Iran and to unveil a new security architecture for the Gulf.