A suicide car bomber attacked a NATO base in southern Afghanistan just hours after a visit by the US defence secretary on Thursday, killing an American soldier and two civilians.
The death of the US soldier and the wounding of three others in the blast was announced by Pentagon chief Leon Panetta at a press conference in Kabul with Afghan President Hamid Karzai.
Seventeen Afghan civilians and one Afghan army soldier were also injured as the bomber detonated his vehicle near the huge International Security Assistance Force (ISAF) airbase in Kandahar city in southern Afghanistan, police said.
Taliban insurgents claimed responsibility for the attack in a text message to AFP.
"The suicide bomber detonated his car as an ISAF convoy was entering the Kandahar airfield," Kandahar provincial police chief General Abdul Razeq told AFP.
US officials said the car struck a heavily-armoured American vehicle but insisted there was no indication that the attack was connected with Panetta's trip.
The Taliban's initial claim made no mention of Panetta, but it was followed by a second text linking the attack to the Pentagon chief's visit.
Panetta played down the incident and struck an upbeat note, saying Afghan forces would soon be ready to take over security for the whole of the country, paving the way for the departure of NATO-led troops in two years.
The former CIA director dismissed the bombing as a desperate tactic by the insurgents who he said were frustrated at the growing strength of Afghan forces.
"This is what they resort to in order to try to continue to try to stimulate chaos in this country. They will not be successful at doing that," he said.
Reporters travelling with Panetta were earlier briefed by senior officers at the base who told them security was steadily improving in the Kandahar region and that the Taliban had been seriously weakened.
The head of NATO-led forces in the area, US Major General Robert Abrams, said the Taliban's capabilities were now "pretty limited".
But he said ISAF had detected "numerous" plots to attack Kandahar airfield that had been disrupted. More than 14,000 US troops are stationed at the base.
During a visit by Panetta to Camp Bastion in neighbouring Helmand province in March, an Afghan died after hijacking a truck and trying to ram it into US Marines waiting to greet the Pentagon chief at the airport.
Last week, Taliban suicide attackers struck at a NATO base at Jalalabad airport in eastern Afghanistan, killing five people and wounding several foreign troops in a two-hour battle, officials said.
The latest assaults came as the summer fighting season should be drawing to a close, suggesting the insurgency remains resilient after surviving the biggest onslaught US-led forces will throw against them.
The last of the additional 33,000 reinforcements US President Barack Obama deployed in a troop "surge" nearly three years ago left in September, and the vast majority of the remaining NATO force of more than 100,000 will follow by the end of 2014.
Panetta's trip to Afghanistan, likely his last before he retires, offered a chance to discuss options with commanders as Obama prepares to decide on the pace of a troop drawdown over the next two years and the size of a potential follow-on force after 2014.
Panetta announced that Obama has invited Karzai to travel to Washington to hold talks with the US president on January 7 "to discuss a shared vision of Afghanistan beyond 2014".
US and Afghan officials have started negotiating terms for a smaller US force to remain after 2014 and both Panetta and Karzai voiced optimism that the two sides would clinch an agreement.
Karzai repeated his stance that Kabul could be willing to grant legal immunity to US troops in return for the United States helping arm the Afghan military and turning over control of all detainees held by American forces.
"We know in Afghanistan the question of immunity for US troops is of immense importance for the United States," he told the news conference.