BEIJING - China on Tuesday defended its friend Pakistan against strong criticism by Donald Trump that the country is not doing enough to counter terrorism.

In a major speech outlining US policy on Afghanistan, the American president slammed Islamabad for offering safe haven to “agents of chaos”.

Successive US administrations have criticised Pakistan for links with the Taliban and for harbouring leading jihadists - like Osama bin Laden.

“We have been paying Pakistan billions and billions of dollars at the same time they are housing the very terrorists that we are fighting,” Trump said, warning that vital aid could be cut.

But Chinese foreign ministry spokeswoman Hua Chunying took a contrary view, telling reporters that Pakistan “has made great sacrifices and contributions to fighting terrorism”.

“The international community should fully affirm the efforts by Pakistan,” she told a regular press briefing.

Beijing is investing around $50 billion in its South Asian neighbour as part of a plan unveiled in 2015 to link its far-western Xinjiang region to the Pakistani port of Gwadar with upgraded infrastructure, power lines and transport links.

But fears over safety arose earlier this year when two Chinese workers were abducted in Quetta.

Pakistan responded by deploying a 15,000-strong military force to protect Chinese working on energy and infrastructure projects in the country.