U.S. President Donald Trump’s decision to order the assassination of Qassem Soleimani, Iran’s most powerful military commander, has raised the specter, albeit still distant, of all-out war between the United States and the Islamic Republic. There is only one winner in this situation: China.

With Trump’s latest blunder, history may not be repeating itself, but it is certainly rhyming. When George W. Bush began his presidency in January 2001, his neoconservative advisers identified China as the biggest long-term threat to the U.S. So his administration labeled China a “strategic competitor” and set to work on containing America’s Asian rival.

In April 2001 — the same month a U.S. Navy spy plane collided with a Chinese fighter jet while on a routine surveillance mission over the South China Sea — the U.S. announced the sale of a weapons package to Taiwan over Chinese protests. Bilateral relations plunged to their lowest point since the normalization of diplomatic ties in 1979.

Everything changed on Sept. 11, 2001, when the U.S. was struck by the single deadliest terrorist attack in history. The Bush administration became so preoccupied with retaliating against al-Qaida — an objective that led to the catastrophic decision to invade Iraq two years later — that it all but forgot the distant specter of an Asian superpower.

Just three months after 9/11, the Bush administration signed off on China’s accession to the World Trade Organization and China’s economy shifted into high gear. In 2000, China’s economic output amounted to $1.21 trillion — less than 12 percent of U.S. GDP. By the end of Bush’s second term, in 2008, China’s GDP had reached $4.6 trillion — more than 31 percent of America’s. Today, China’s GDP stands at about 65 percent of the U.S. level.

In this sense, China owes its “economic miracle” to the 9/11 terrorist attacks — or, more precisely, to the Bush administration’s disastrous response. Two decades from now, we may well be saying the same about the Soleimani assassination.

Like Bush, when Trump entered the White House, his administration quickly branded China America’s top geopolitical adversary and adopted a confrontational policy, exemplified by a trade war that, despite a “phase one” agreement, has yet to be resolved. In effect, Trump revived great power competition — focused primarily on containing China — as the organizing principle of U.S. foreign policy.

Then Trump had Soleimani killed and all eyes turned toward Iran. If the conflict continues to escalate — even if it stops short of all-out war — the U.S. will most likely redirect significant resources toward confronting the Islamic Republic, and, like after 9/11, move China to the foreign policy back burner.

For Chinese President Xi Jinping, capitalizing on this shift will require a carefully calibrated response. The events unfolding in the Middle East present a tantalizing strategic opportunity for China. But, as Xi probably recognizes, his best bet is to declare support for Iran — and continue to import Iranian oil surreptitiously, in defiance of U.S. sanctions — but avoid provoking Trump, say, by supplying weapons to the Iranians.

But, even as China limits its involvement, it cannot go entirely unnoticed. The country’s growing power — and America’s interest in containing it — will factor into the strategic calculus of both sides in the U.S.-Iran conflict.

Iran has already effectively declared that the 2015 nuclear deal, the Joint Comprehensive Plan of Action, is dead, announcing that its nuclear program will now have “no limitations in production, including enrichment capacity.” If Iran’s leaders believe that the U.S. will seek to avoid committing the same strategic mistakes as Bush, including vis-a-vis China, they may opt for bolder retaliation.

As for the U.S., the more sober-minded in Washington will undoubtedly advocate a measured response to any Iranian retaliation, not least to avoid losing sight of the China challenge. But Trump’s own calculations are driven largely by his desire to present a “tough guy” image to voters in advance of this November’s presidential election (precisely what he accused his predecessor Barack Obama of planning in 2011). And he is surrounded by far more inexperienced sycophants than qualified advisers.

Seventeen years ago, Bush entered into a war of choice in the Middle East that, besides costing huge amounts of U.S. blood and treasure, derailed efforts to contain China. Trump can still avoid making the same mistake. But with every unhinged tweet — for example, threatening to attack Iranian cultural sites (a war crime) if the country retaliates — the chances that strategic sanity will prevail seem to grow smaller and Xi’s hopes for the new year grow brighter.

Minxin Pei is a professor of government at Claremont McKenna College and a senior fellow at the German Marshall Fund of the United States.©Project Syndicate, 2020