Secretary of State Rex Tillerson renewed US support for Afghanistan in a surprise visit on Monday, days after the Taliban launched a spate of attacks they described as a "message" to America.
Tillerson is only the second member of Donald Trump's cabinet to visit the war-torn country since the US president's pledge in August to stay the course in America's longest war and send more troops.
His unannounced trip comes after one of the bloodiest weeks in Afghanistan in recent memory as the Taliban attacked multiple security installations and Islamic State bombed a mosque in the Afghan capital.
The visit of America's top diplomat to Afghanistan was preceded by several rockets fired into Kabul on Monday morning by militants, but there were no casualties.
The meeting between Tillerson, Afghan President Ashraf Ghani and Chief Executive Abdullah Abdullah took place at the heavily protected Bagram Airfield, America's largest base in the country.
Tillerson reaffirmed the US committment to working with the Kabul government and regional partners "to achieve peace in Afghanistan and deny safe havens to terrorists who threaten that goal", the US embassy said on Twitter.
"Clearly we have to continue to fight against the Taliban, against others, in order for them to understand they will never win a military victory," Tillerson told reporters after the meeting.
It was Tillerson's first trip to Afghanistan as secretary of state and comes several weeks after US Defence Secretary Jim Mattis also paid an unannounced visit.
During Mattis's visit last month Taliban militants fired multiple rockets towards Kabul's international airport in an attack that killed one person and wounded 11 others.
The closed-door talks on Monday covered Ghani's reform programme, anti-corruption strategy and preparations for parliamentary elections due to take place next year.
Trump "has declared that we are here to stay until we can secure a process of reconciliation and peace", Tillerson said, adding: "It's not an unlimited commitment."
The US has vowed to deploy more than 3,000 additional troops, on top of the 11,000 already in Afghanistan, to train and advise Afghan security forces as part of a new strategy outlined by Trump in August.
A spokesman for the Taliban told AFP last week the recent spate of attacks was "a clear message... The enemy who thought they had scared us with the new Trump strategy have now been given a lesson".
Warning to Pakistan
The Taliban has been rampant since the withdrawal of US-led Nato combat forces at the end of 2014. Trump's open-ended committment to put more American boots on the ground and a surge in US airstrikes has further fuelled the insurgency.
Tillerson is due to fly to Pakistan on Tuesday where he will pressure Islamabad to take action on the support Taliban and other "terrorist organisations" receive in the country.
Pakistan needs to "take a clear-eyed view of the situation that they are confronted with in terms of the number of terrorist organisations that find safe haven inside" the country, Tillerson said.
"We want to work closely (with) Pakistan to create a more stable and secure Pakistan as well," he said.
In August Tillerson warned an angry Pakistan that it could lose its status as a privileged military ally if it continued giving safe haven to Afghan militant groups.
Islamabad has long denied Washington's accusation it is helping the Taliban, adding that the claim belittles the thousands of lives it has lost and billions it has spent in fighting militancy.
As one of 16 "Non-Nato Major Allies", Pakistan benefits from billions of dollars in aid and has access to some advanced US military technology banned from other countries.
For his part, Ghani reiterated his support for the US strategy, saying it would result in "a positive change in the region", according to a statement issued by the presidential palace.
But in a thinly veiled attack on Pakistan, Ghani said "all partners should play their roles with honesty".