US Secretary of State John Kerry vowed in Kabul to stick by Afghanistan as President Hamid Karzai, after a series of fiery outbursts, hailed a "good day" for ties with the handover of a military jail.
Kerry came to Afghanistan on an unannounced visit just after the United States, acceding to a long-standing demand of Karzai, delivered full control of the prison at Bagram to Afghan forces.
Karzai had turned the fate of Bagram and its hundreds of detainees into a rallying cry for his ill-tempered push to grab back sovereignty from the Americans, as US-led combat troops wind down more than a decade of war.
Both the Afghan leader and Kerry appeared keen to move on.
"Today was a good day for Afghanistan. Bagram prison was handed over to the Afghan government... Finally after many years of effort we have reached a deal," Karzai told reporters.
Kerry said: "The US is committed to an enduring partnership... The US supports a strong and united Afghanistan.
"We are committed to Afghanistan's sovereignty and we will not let Al-Qaeda or the Taliban shake this commitment."
Earlier this month, the Afghan president accused the US of working in concert with the Taliban and his spokesman described the coalition's war effort as "aimless and unwise", triggering fury from Afghanistan's foreign backers.
Responding to a storm of protest over the collusion allegations, Kerry said he was confident Karzai "absolutely does not believe that the United States has any interest except to see the Taliban come to the table to make peace".
For his part, Karzai said: "I was interpreted as saying the US and Taliban are colluding, but I did not use this word."
Afghan troops and police are gradually taking on responsibility for battling the Taliban as most of the 100,000 foreign troops prepare to exit by the end of 2014.
Australia on Tuesday said it was withdrawing the bulk of its 1,550 troops this year, with the closure of their main base in Uruzgan province.
"We've been there for over a decade, and that's far too long," Defence Minister Stephen Smith said, adding that the war was "the easiest thing in the world to get in, hardest thing in the world to get out".
Karzai is due to step down at elections next year, 13 years after he came to power with US backing when the hardline Taliban regime was ousted in the aftermath of the September 11 attacks of 2001.
The military and political calendars are lending added urgency to the search for a negotiated settlement to resolve Afghanistan's decades of conflict.
Karzai said he plans to visit Qatar shortly, with US backing, to discuss the proposed opening of a Taliban office in the Gulf emirate as a prelude to possible peace talks.
"Those who come on behalf of the Taliban can talk and they have the right to talk to all Afghans," he said.
However, the Taliban refuse to communicate directly with Karzai, whom they view as a puppet of the United States.
"The Taliban will hopefully understand that peace and peace talks are the best way to resolve differences," Kerry said.
The long war is increasingly unpopular in the United States, and the latest outbursts from Karzai had led many US commentators to call for Washington to take a tougher stance towards Kabul.
The Afghan leader in past weeks has also demanded US special forces leave the flashpoint province of Wardak and banned international troops from university campuses, both due to unproven harassment claims.
But Karzai appeared keen to repair damaged ties with his acclamation of the handover of Bagram, a sprawling detention centre north of Kabul.
The United States was long concerned that a total handover to Afghanistan's weak and corruption-prone security forces would allow suspected Taliban and Al-Qaeda militants housed at Bagram to return to the battlefield.
But a final agreement was sealed on Saturday, and a handover ceremony was held at the jail shortly before Kerry flew into Kabul from the Middle East.