If America, India or anyone else attacked Pakistan, we will stand by Pakistan," Afghan President Hamid Karzai said in an interview aired by Pakistan private television channel Geo late Saturday.
"Afghanistan is a brother of Pakistan, we will never betray Pakistan," he added.
Karzai's reassuring words for Pakistan follow the signing of a strategic partnership between Afghanistan and India this month that raised fears in Islamabad as it eyes the regional influence of its arch-foe.
Indian involvement in Afghanistan is extremely sensitive because of the delicate and often deadly power games in South Asia, with Pakistan vehemently opposed to its rival neighbour meddling in what it considers its backyard.
The alliance -- the first such pact between Kabul and another country -- deepens already friendly ties and aims to boost trade, security and cultural links.
It will see India, which has given more than $2 billion in aid to the war-torn country, take a bigger role in training Afghan troops and security forces.
Relations between Pakistan and Afghanistan have been severely strained after Karzai accused his neighbour of playing a "double-game" with Afghan insurgents fighting the US-led war effort who hold rear bases across the border.
But Karzai sought to assuage Pakistani fears over US influence in the region following the drawdown of Western combat forces by the end of 2014 and restated his conditions for a long term US partnership.
"God forbid, If any time war erupts between Pakistan and America, Afghanistan will side with Pakistan.
"If Pakistan is attacked and if the people of Pakistan needs Afghanistan's help, Afghanistan will be there with you," he told Geo.
Afghanistan's conditions for a US deal include that American troops must not enter Afghan homes, implying that they should end controversial night raids in pursuit of Taliban targets that have caused many civilian casualties.