The government said the siege had steeled its resolve to go through with the offensive. The United States and Islamabad's other Western allies want the country to take more action against insurgents also blamed for soaring attacks on U.S. and NATO troops in Afghanistan.
Explosions and gunshots rang out as commandos moved into a building in the complex just before dawn Sunday, while a helicopter hovered in the sky. Three ambulances were seen driving out of the heavily fortified base close to the capital, Islamabad.
Two hours after the raid began, two new explosions were heard. The army said it was "mopping up" the remaining insurgents.
Up to five heavily armed militants took the hostages after they and about four other assailants attacked the main gate of the army headquarters Saturday, killing six soldiers, included a brigadier and a lieutenant colonel. Four of the attackers, who were wearing army uniforms, were killed.
No group claimed responsibility, but authorities said they were sure that the Pakistani Taliban or an allied Islamist militant group were behind the strike. The city is filled with security checkpoints and police roadblocks.
Abbas said 20 of the hostages had been kept in a room guarded by a militant wearing a suicide vest who was shot and killed before he managed to detonate his explosives.
He said the 22 who were freed included soldiers and civilians. Three captives were killed, along with four militants, he said. "It was a very skilled rescue operation," he said.
It was unclear if any of the hostage-takers survived the raid.
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 earlier in the week that killed five in Islamabad. The string of attacks destroyed any remaining hope that the militants had been left a spent force by the death of Pakistani Taliban chief Baitullah Mehsud in a U.S. missile strike in August.
The army - which until 2001 had patronized various militant groups for use as proxies in Afghanistan and India - had previously been unwilling to go into Waziristan. Three earlier offensives there have ended in failure, and no one thinks the fight against an estimated 10,000 well-armed fighters there will be any easier this time.
But there are hopes the army may have learned from its successful operation in the northwestern Swat Valley this year.
"I want to give a message to the Taliban that what we did with you in Swat, we will do to you there (in Waziristan), too," said Interior Minister Rehman Malik. "We are going to come heavy on you."
In its brazenness and sophistication, Saturday's 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 eight hours before security forces retook it.
The attack began shortly before noon when the gunmen attacked the main gate with assault rifles and grenades after bundling out of a white van that reportedly had army license plates.
"There was fierce firing, and then there was a blast," said Khan Bahadur, a shuttle van driver who was standing outside the gate. "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, who 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.
A police intelligence report obtained by The Associated Press on Saturday had warned in July 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 that they had raided a house in the capital where the attackers were believed to have stayed. They found military uniforms and bomb-making equipment.
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. ----
Associated Press writer Chris Brummitt and Asif Shahzad contributed to this report from Islamabad.