Xi Jinping, the Chinese president, is not a man predisposed to smiling. And yet, as I watched Donald Trump outline his Afghanistan strategy, I could easily imagine his face lighting up. If there is one clear winner of the new approach in Afghanistan, it is China.

The sternest rebuke in Trump’s speech was aimed at Pakistan. He called on Islamabad to “demonstrate its commitment to civilisation, order and peace” and said that the US could no longer stay silent about its “safe havens for terrorists”. While previous administrations have also voiced concerns, Trump decided to skip any subtlety and take a primetime dig at a non-Nato ally.

This is a serious strategic mistake. While Pakistan has harboured militants, its role has also evolved. It helps the US and its allies fight al-Qaida and the Taliban. It is also a crucial supply route for Nato troops in Afghanistan. The speech threatens to push Pakistan closer to China and jeopardises the fragile civil-military balance in the south Asian nation. In one speech, Trump has undone years of careful diplomacy in the region.

Pakistan’s close relationship with China goes back to 1950, when it became one of the first countries to recognise the new communist regime. The bonds are now so close they pose a threat to Indian and US interests. Beijing is planning to invest more than $55bn as part of the China-Pakistan economic corridor and in March, its soldiers marched in a foreign parade during Pakistan’s national day celebrations.

In a clear sign that Trump’s speech will bring the two even closer, China rushed to defend its ally, saying Pakistan “is at the frontline of fighting terrorism”.

PML-N supporters in Multan, Pakistan, protest after Trump’s statement. Photograph: Faisal Kareem/EPA

Close ties between China and Pakistan are a problem for the US because it wants to use India to counterbalance China’s rise in the region. China supplies arms and funds to Pakistan, partly to keep tensions high on its border with India. A Pakistani ambassador to the US admitted as much when he called his country “a low-cost secondary deterrent to India”. With India distracted, China can then grow unchallenged in the region. Keeping Pakistan on side and preventing China from becoming its primary patron is thus crucial for the US.

The civilian government in Pakistan will also suffer because of Trump’s speech. The military in Pakistan has used the threat of India as a bogeyman to get a large slice of the budget and resist civilian meddling. Its influence has grown so large that some local television stations have instituted a 30-second buffer in live broadcasts to mute any criticism of the army.

The likelihood of a military coup in Pakistan would increase in the absence of a strong benefactor supporting democracy

Recently, the US has been an ally for Pakistan’s civilian governments struggling to rein in the army. A 2011 diplomatic crisis illustrates this: the then-Pakistani ambassador to the US, Husain Haqqani, was forced to resign for compiling a memo asking the US to help avert a coup by his own army. No such call would ever go out to Beijing, because it has no soft spot for democracy. The likelihood of a military coup in Pakistan would increase substantially in the absence of a strong benefactor supporting democracy.

Finally, the speech was also counterproductive because of the call on India to “help more with Afghanistan”. Inviting Pakistan’s nuclear rival to intervene in Afghanistan is wholly counterproductive if the aim is to get Islamabad to back off. What is more, any hint that India is expanding activities in Afghanistan – militarily or otherwise – would again allow the Pakistani army to raise the spectre of Indian encirclement and tilt the civil-military balance in its favour.

There is a reason diplomacy is generally bereft of loud posturing. It is detrimental when dealing with complex issues, like an ally that is both wayward and critical. Barack Obama understood this as US president, and pressed Pakistan more subtly. Trump, as usual, has failed to grasp any nuance, choosing posturing over real effective diplomacy. A maestro of own goals, he has struck another one for US foreign policy.

• Abhishek Parajuli is Clarendon scholar at the University of Oxford and Peter Martin fellow at the Financial Times