The government said the assault on the headquarters, which followed a bloody market bombing and a suicide blast at a U.N. aid agency in the past week, had strengthened its resolve to push into South Waziristan - a mountainous region home to al-Qaida leaders where security forces have been beaten back by insurgents before.
The spasm of violence was confirmation that the militants had regrouped despite recent military operations against their forces and the killing of Pakistani Taliban leader Baitullah Mehsud in a CIA drone attack in August. His replacement vowed just last week to step up attacks around the country and repel any push into Waziristan.
Army spokesman Maj. Gen. Athar Abbas said "four or five" assailants were holding between 10 and 15 troops hostage in a building close to the main gates of the complex in Rawalpindi, a city near the capital, Islamabad. No senior military or intelligence officials were among those being held, he said.
Abbas said special forces had surrounded the building. "They will decide how and when to act," he said, declining to comment on whether authorities had attempted to talk to the hostage takers or whether they had made any demands.
No group claimed responsibility, but authorities were sure that the Pakistani Taliban or an allied Islamist militant group were behind it.
Late Saturday, sporadic gunfire was heard coming from the complex.
In its brazenness and sophistication, the assault resembled attacks in March in the eastern city of Lahore by teams of militants against the visiting Sri Lankan cricket team and a police training center, which the insurgents took over for 12 hours before security forces retook it.
Saturday's attack began shortly before noon when the gunmen, dressed in camouflage military uniforms and wielding assault rifles and grenades, drove in a white van up to the army compound and opened fire, Abbas and a witness said.
"There was fierce firing, and then there was a blast," said Khan Bahadur, a shuttle van driver who was standing outside the gate of the compound. "Soldiers were running here and there," he said. "The firing continued for about a half-hour. There was smoke everywhere. Then there was a break, and then firing again."
After a 45-minute gunfight, four of the attackers were killed, said Abbas.
He initially told the Geo television news channel that the assault was over and the situation "under full control."
But more than an hour later, gunshots rang out from the headquarters compound, and Abbas then confirmed that other gunmen had eluded security forces and slipped into the compound. The city is filled with security checkpoints and police roadblocks.
"We are trying to finish it (the siege) at the earliest, clear the area of terrorists and restore complete control," Abbas said. Abbas said six soldiers were killed, included a brigadier and a lieutenant colonel, and five wounded, one critically.
Pakistani media said the Taliban had claimed responsibility for the attack.
A police intelligence report in July obtained by the Associated Press on Saturday warned that members of the Taliban along with Jaish-e-Mohammed, a militant group based in the country's Punjab province, were planning to attack army headquarters after disguising themselves as soldiers. The report was given to the AP by an official in the home affairs ministry in Punjab's home department.
Officials said Saturday they had raided a house in the capital where the attackers were believed to have stayed. They found military uniforms and bomb-making equipment.
The United States has been pushing Pakistan to take strong action against insurgents using its soil as a base for attacks in Afghanistan. The army has previously been unwilling to go into Waziristan with significant force, but has likely been emboldened by its successes against the militants in the Swat Valley earlier this year and the killing of Baitullah Mehsud.
"I want to give a message to the Taliban that what we did with you in Swat, we will do the same to you there (in Waziristan), too," said Interior Minister Rehman Malik. "We are going to come heavy on you."
Militants regularly attack army bases across the country and bombed a checkpoint outside the army compound in Rawalpindi two years ago - one of several major bombings to hit the garrison city in recent years. But rarely have the Taliban mounted an armed assault in the city involving multiple fighters.
Saturday's siege followed a car bombing that killed 49 on Friday in the northwestern city of Peshawar and the bombing of a U.N. aid agency Monday that killed five in Islamabad. The attacks showed the militants are capable of striking a range of targets across the country.
The man who attacked the U.N. office was also wearing a security forces' uniform and was granted entry to the compound after asking to use the bathroom.
Islamist militants have been carrying out nearly weekly attacks in Pakistan, but the sheer scale of Friday's bombing in Peshawar - which killed nine children - pushed the government to declare it would take the fight to the lawless tribal belt along the border where al-Qaida leader Osama bin Laden may be hiding.
Any operation in Waziristan will be very difficult. Militants are believed to have 10,000 well-armed fighters there, and winter will arrive in one month's time and could bog down troops. The army must also ensure that insurgents do not regroup elsewhere in the northwest, including Swat.
Associated Press writer Munir Ahmad and Chris Brummitt contributed to this report from Islamabad.