At first glance, a sweeping 25-year strategic partnership signed by China and Iran late last month makes a lot of sense. Iran is an oil-rich nation with regional ambitions but a crumbling economy. China is the world’s biggest oil importer with grand plans to construct a “new silk road” across the Eurasian landmass. Yet the agreement is perilous for both sides — and could be a new source of instability just as America is poised to end its “forever wars” in the region.

The Iranian regime has faced widespread domestic opposition to the deal since a draft was first made public last year. The announcement during the Persian new year holidays and Tehran’s unwillingness to publish any details were tacit acknowledgment of the agreement’s unpopularity. Beijing’s tendency to underdeliver on promised infrastructure projects and Chinese infringement on sovereignty in other silk road countries also pose risks for Iran’s leaders.

For China, the stakes are probably higher. Beijing has long prided itself on being friends with all sides in the Middle East. On the same trip that took him to Tehran last month, Chinese foreign minister Wang Yi visited Iran’s arch-enemy Saudi Arabia, as well as Turkey, the United Arab Emirates, Oman and Bahrain. Much deeper Chinese ties with Iran will cause consternation in Israel, Saudi Arabia and other countries in the region and could suck Beijing into conflicts it neither wants nor understands. A Chinese offer to host direct talks between Israel and the Palestinians looks provocative at best and naive at worst.

One of the most important consequences of the Iran agreement will be the alarm bells it sets off in the White House and the Pentagon. China’s leaders have already made clear they believe the US-led west is in terminal decline, while China is on an inexorable path to “great rejuvenation”. The prospect of an axis of authoritarian countries — possibly including Russia — united in their antipathy towards America and the west is the stuff of nightmares in Washington and Europe.

Intentionally or not, President Xi Jinping is constantly contributing to that impression with actions such as the Iran agreement and when he commands his diplomats to “dare and draw their dazzling swords” and the military to “fight and win wars”.

Ever since China became a net importer of oil in the 1990s, the country’s strategic planners have tried to reduce reliance on strategic waterways in the gulf and in south-east Asia that the US navy could block at will. But under Xi, the strategy has shifted. With investments in military and civilian ports and facilities throughout the Middle East, Beijing does not only want to loosen America’s chokehold on Chinese energy supplies in the event of a conflict. It appears to want the ability to cut off those supplies to US allies in Asia if it ever came to that.

Some within the senior ranks of the Chinese Communist party grumble this posturing could spur conflict with the US long before China can win.

The Biden administration should resist overreacting to the prospect of an authoritarian alliance. In some ways, Iran’s deal with Beijing looks like attention seeking from Tehran, when all it really wants is a return to warming relations with the west.

Indirect talks between Washington and Tehran in Vienna last week were a good start. Rejoining the Iran nuclear deal under acceptable terms should be a priority. But the Sino-Iranian agreement is a timely reminder for America that the end of its longest wars will not — and should not — mean the end of its involvement in the region.