Eleven Taliban homicide bombers attacked government buildings in eastern Afghanistan on Tuesday, sparking running gunbattles that killed at least 20 people and wounded three U.S. troops, officials said. U.S. and Afghan troops freed 20 hostages taken by the insurgents.

The assault began around 10 a.m. when a homicide bomber in a burqa attacked the governor's compound in Khost, an eastern city on the border with Pakistan that houses a major American base. That blast was followed soon after by a homicide car bomb explosion, said Wazir Pacha, the spokesman for the provincial police chief.

U.S. forces attending a nearby meeting responded to the attacks and killed an unknown number of militants, said Lt. Cmdr. Christine Sidenstricker, a U.S. military spokeswoman.

Khost residents hid from booming explosions and running street clashes that lasted until 5 p.m. At least eleven insurgents and nine others — including police and civilians — died, the Defense Ministry said.

A Taliban spokesman, Zabiullah Mujahid, claimed that 30 homicide bombers had attacked the government buildings. A U.S. spokesman summed up the chaos in the midst of battle: "A lot of stuff is going on right now."

Militants in recent months have carried out an increasing number of complex attacks that involved several assailants. Military analysts have said the increasing sophistication of attacks in Afghanistan is a result of training by Pakistani militants and Al Qaeda fighters.

The Khost attack came as President Obama sought to put his stamp on the war, appointing a former three-star general as the country's ambassador and replacing the top American military commander in Afghanistan. Karl Eikenberry presented his credentials to President Hamid Karzai on Tuesday.

The attack began with several homicide attacks on the Khost governor's compound, which drew small arms fire from nearby U.S. troops, said U.S. military spokesman Chief Brian Naranjo.

Then a team of six homicide bombers tried to attack the nearby police headquarters, but were rebuffed by security forces and entered the neighboring municipality building, Pacha said.

Three bombers detonated their explosives, the Interior Ministry said, while other militants took 20 city employees hostage, Pacha said.

A second U.S. team was sent from the nearby American base, Camp Salerno. But those troops were fired on en route, Naranjo said. A U.S. soldier and an Afghan policeman were wounded and taken to Camp Salerno for treatment where they were in stable condition, he said. A number of militants were killed, he said.

After the militants entered the municipal building, a number of explosions reverberated from within, as U.S. and Afghan forces surrounded the area, an Associated Press stringer said from within the police chief's compound.

U.S. and Afghan forces later stormed the building, freed 20 hostages and killed three insurgents, Pacha said.

Taliban and other insurgent fighters have increased their attacks the last three years and now control wide swaths of territory, and Obama is seeking to reverse their momentum.

To that end, the Pentagon fired Gen. David McKiernan as the top U.S. commander in the country and replaced him Monday with Lt. Gen. Stanley McChrystal, a former leader of special forces.

Gen. Mohammad Zahir Azimi, Afghanistan's Defense Ministry spokesman, listed three priorities that McChrystal should focus on when taking over the command.

"Prevent civilian casualties, strengthen the quality and quantity of Afghan forces, and focus more on coordinating the military operations with Afghan forces," Azimi said.

McKiernan's exit comes as more than 21,000 additional U.S. forces begin to arrive in Afghanistan — dispatched by Obama to confront the Taliban more forcefully. A record 38,000 U.S. troops are already in the country.