Pakistan was angered in 2011 when US troops entered the country and killed al-Qaeda leader Osama bin Laden without bothering to tell Islamabad of its plans, another snub after years of criticism of the country as a safe haven for terrorists.
In August this year, President Donald Trump took Pakistan to task over its alleged support for the Taliban and allied groups that attack US and Afghan government interests across the porous frontier with the Pakistani semi-autonomous tribal areas.
“The situation between the two countries has deteriorated in the sense that Trump's policy singles out Pakistan,” says Imtiaz Gul, the director of the Centre for Research and Security Studies in Islamabad. “It has also assigned India, Pakistan’s next-door neighbour, as a strategic partner for cooperation in South Asia and in Afghanistan.
“That policy did not go down well with Pakistan and it feels that it has been unfairly treated by the Trump administration."
India and Pakistan have been rivals since independence from British colonialism and Pakistani politicians and soldiers fear "strategic encirclement" as Delhi's influence in Afghanistan grows.
Other analysts speak of an “all-time low” in the once flourishing Pakistan-US security relationship in the heyday of the Cold War.
“We see the US being very pronounced in its commitment to put more pressure on Pakistan,” says Christian Berg Harpviken, a research professor with the Peace Research Institute in Oslo. "That may mean sanctions, reducing aid and putting the country on a list of states that sponsor terrorism.
“We also see Pakistani leaders saying ‘Enough is enough.’ US leverage over Pakistan is not what it used to be, they don’t get much out of the US anyhow, and now they want to stand up for their own rights. So I think we are possibly headed here for a quite direct confrontation.”
Mumbai attacks suspect freed
On 24 November Pakistan released the Jamaat-ud-Dawa leader Hafiz Saeed, who was allegedly involved in planning 2008's Mumbai attacks.
Both India and the US have declared Saeed a terrorist, while Washington has put a 10-million-dollar bounty on his head.
To add insult to injury, Saeed has announced that he wants to stand in the 2018 general election on behalg of the Milli Muslim League (MML), a party that was formed by his Jamaat-ud-Dawa when he was in jail.
Pressure over Afghan insurgents
But if the US wants to cite Saeed’s release as proof that Pakistan is soft on terrorists, it is unlikely to make much impression on Islamabad.
“Everybody in Pakistan knows what message Mattis, the defense secretary, has brought,” says Gul, adding that Washington’s policy seems to “single out Pakistan as a source for problems for Afghanistan".
The Pakistani response so far is that only some of the 20-odd non-state actors operating in Afghanistan may be hiding in the Pakistani territory, says Gul.
It the exact opposite of what Mattis thinks.
“He believes firmly that the only way to succeed in Afghanistan is to pressure Pakistan into withdrawing its support and indeed its harbouring of members of the Taliban,” says Harpviken.
“But whether that is going to be successful is certainly in doubt.”
China, the 'all-weather friend'
Meanwhile, Pakistan is looking the other way, getting closer to its “all-weather friend” China.
“At the moment, China is wooing Pakistan quite strongly,” says Kamal Chenoy, a political scientist with the Jawarhalal Nehru University in Delhi.
A major sweetener is Beijing's One Belt-One Road programme, a massive construction plan designed to create the world’s largest land and sea transport network, wich will connect east Asia to Europe and Africa.
China is investing heavily in railways and ports in Pakistan and has already constructed a complete port in Gwadar, east of Karachi.
There there are security concerns in this relationship as well.
“China is not mentioning the terror aspect in Pakistan,” says Chenoy. “ And it claims it has its own serious problem, in Xinjiang, with the Uighurs [China’s restive Muslim minority]. So they are trying to keep Pakistan on their side.
"But it is basically a competition game at the moment. And it depends on how much pressure the US is prepared to put on Pakistan and how much China wants to invest.”
With China offering development and no questions asked, Pakistan has a certain independence that may allow it to shrug off some or all of Mattis's and Trump's complaints.