China defended its ally Pakistan on Tuesday after the US President Donald Trump said the United States could no longer be silent about Pakistan's "safe havens" for militants and warned it had much to lose by continuing to "harbour terrorists".Trump on Monday committed the United States to an open-ended conflict in Afghanistan, signalling he would dispatch more troops to America's longest war and vowing "a fight to win".Trump insisted that others - the Afghan government, Pakistan, India and NATO allies - step up their own commitment to resolving the 16-year conflict, but he saved his sharpest words for Pakistan.Senior US officials warned security assistance for Pakistan could be reduced unless the nuclear-armed nation cooperated more in preventing militants from using safe havens on its soil.Critics say Pakistan sees militants such as the Taliban as useful tools to limit the influence of old rival India. Pakistan denies allowing militants refuge on its territory, saying it takes action against all groups.Asked about Trump's speech, Chinese Foreign Ministry spokesperson Hua Chunying said Pakistan was on the front line in the struggle against terrorism and had made "great sacrifices" and "important contributions" in the fight."We believe that the international community should fully recognise Pakistan's anti-terrorism," she told a daily news briefing."We are happy to see Pakistan and the United States carry out anti-terror cooperation on the basis of mutual respect, and work together for security and stability in the region and world."China and Pakistan consider each other "all-weather friends" and have close diplomatic, economic and security ties.China has its own security concerns in the region, in particular any links between militants in Pakistan and Afghanistan and Islamist groups China blames for violence in its far western region of Xinjiang."We hope the relevant US policies can help promote the security, stability and development of Afghanistan and the region," Hua said.