Cricket star turned opposition leader Imran Khan has criticised Donald Trump as “ignorant and ungrateful” after the US president accused Pakistan of harbouring terrorists.

Mr Khan also taunted the Trump administration by challenging the president to explain how “a couple of thousand or so (Taliban-allied) Haqqanis allegedly in Pakistan are supposed to be the cause of why the most well-equipped military force in history … cannot succeed” in Afghanistan.

In a series of rambling tweets, Mr Khan also criticised Pakistan’s participation in the US-led war on terror in which Islamabad is a US ally.

He said he opposed the war on terror from its outset.

The cricketing hero, with a reputation internationally as a playboy and in Pakistan as an Islamic conservative, has ambitions to be Pakistan’s next prime minister.

Mr Khan’s denunciation followed top Islamabad officials’ response to Mr Trump’s New Year’s Day tweet against Pakistan.

Washington has confirmed it will withhold 255 million dollars (£188 million) in US military aid to Pakistan this year, following a threat from last August when Mr Trump announced an Afghan policy which took aim at neighbouring Pakistan, demanding an end to Islamabad’s alleged support for the Afghan Taliban.

Pakistan denies supporting militants, pointing to its own war against extremist groups battling to overthrow the government.

Pakistani protesters burn banners showing Donald Trump
Pakistani protesters burn banners showing Donald Trump in Hyderabad (Pervez Masih/PA)

The war in Afghanistan has now entered its 17th year, with an ever-growing mix of insurgents and militant factions operating in the country, including an Islamic State affiliate in the region.

“Pakistan has now suffered the ultimate insult (by) being made the scapegoat for US failures in Afghanistan,” Mr Khan tweeted.

On Monday, Mr Trump tweeted that the US had “foolishly” given Pakistan more than 33 billion dollars in aid in the last 15 years and had gotten nothing in return but “lies & deceit”.

At a top security meeting on Tuesday, Pakistan’s civilian and military leadership said Mr Trump’s tweet ran counter to meetings held with US secretary of state Rex Tillerson and defence secretary Jim Mattis following the announcement of Mr Trump’s Afghan policy.

A statement after the meeting described talks with Mr Tillerson and Mr Mattis as “robust and forward-looking”.

It also described Mr Trump’s New Year’s Day tweet as “completely incomprehensible”.

White House press secretary Sarah Huckabee Sanders told reporters on Tuesday to expect more details on specific actions against Pakistan over the next day or two.