Afghan National Army troops keep watch after gunmen attacked a foreign military base in Kandahar on Thursday. (AHMAD NADEEM/Reuters)

Taliban fighters launched separate attacks on two U.S. bases in Kandahar on Thursday, exploding a car bomb outside a military outpost west of the city and firing rocket-propelled grenades at another garrison downtown, according to U.S. and Afghan officials.

The violence, which killed at least three Afghans and wounded six Americans, indicated that the Taliban still has the ambition and ability to take on the symbols of American power in southern Afghanistan. U.S. officials have been encouraged by months of declining violence in Kandahar city and some of the surrounding farmlands, but the insurgents have carried out high-profile assassinations in recent months that have tested the emerging stability.

The attack downtown began at 2:15 p.m., when four Taliban fighters fired rocket-propelled grenades and small arms at Camp Nathan Smith, the U.S.-run headquarters of the provincial reconstruction team, which houses State Department officials and U.S. soldiers who focus on improving governance and development in the area.

Over the course of six hours, tower guards and an Afghan police SWAT team exchanged gunfire with the insurgents, who were holed up on the top floor of a three-story building 100 to 200 yards from the base, said Maj. Kevin Toner, a U.S. military spokesman at the base. About 10 rocket-propelled grenades landed in or near the compound, and at least two car bombs exploded outside, he said.

The police SWAT team, commanded by the provincial police chief, Gen. Abdul Razziq, cleared the first two floors of the building then stopped at the top floor, where the door was barricaded with barbed wire, Toner said.

“They did not want to breach that,” not knowing what was on the other side, he said.

About 8:30 p.m., a U.S. military helicopter fired a Hellfire missile into the building, ending the standoff, Toner said.

“They made no attempts here to breach the gate. It was just shooting at us from that compound,” Toner said.

The explosions inside the base killed an Afghan civilian and wounded five American soldiers, an American civilian contractor and an Afghan soldier, Toner said. The head of Kandahar’s health department said that one police officer also died and another was wounded.

U.S. Embassy spokesman Gavin Sundwall said in a statement that “the civilians who serve in Afghanistan will not be intimidated by this kind of cowardly attack.”

The other attack occurred in Panjwayi, a rural district to the west of the city. A suicide car bomb exploded outside Combat Outpost Pul, a U.S. military base. A U.S. military spokesman in Kandahar said that no American troops were killed or wounded in the blast and that the base perimeter had not been breached. One Afghan civilian died in that attack.

Special correspondents Javed Hamdard and Sayed Salahuddin contributed to this report.