Pakistan - Pakistani commandos stormed an office building Sunday and rescued 39 people taken hostage by suspected Taliban militants after a brazen attack on the army's headquarters.

Saturday's attack on the tightly guarded army headquarters in the city of Rawalpindi, next door to the capital, Islamabad, came as the military prepared an offensive against the militants in their stronghold of South Waziristan on the Afghan border.

The strike at the heart of the powerful military called into question government assertions the militants were virtually crippled by recent setbacks. But a top official said it only underlined the need to finish them off.

The United States condemned the attack and expressed confidence in the security of its ally's nuclear arsenal.

Three hostages, two commandos and four of the gunmen were killed in the pre-dawn rescue operation, said army spokesman Major General Athar Abbas. One wounded gunman was captured and Abbas said he was the ringleader.

Now there is no terrorist left there. The operation is over, Abbas told Reuters.

Pakistani Taliban militants linked to al Qaeda have launched numerous attacks over the past couple of years, most aimed at the government and security forces, including bomb attacks in Rawalpindi.

Saturday, gunmen wearing army uniforms attacked the army headquarters, killing six soldiers including a brigadier and a lieutenant colonel in a gunbattle at a main gate.

Five gunmen were killed there and two of their wounded colleagues captured. But others fled and took hostages in a building housing security offices near the headquarters.

Commandos launched their assault under cover of darkness with a blast and gunfire erupting at 6 a.m. (8 p.m. Saturday EDT).

They were in a room with a terrorist who was wearing a suicide jacket but the commandos acted promptly and gunned him down before he could pull the trigger, Abbas said of one large group of hostages.

Three of the hostages were killed due to militant firing, he said. More hostages were later found alive.

The raid bore the hallmarks of several similarly ruthless swarm attacks this year.

In March, gunmen attacked Sri Lanka's cricket team as it drove to a match in the city of Lahore and weeks later militants raided a police cadet college in the same city.

Those attacks were blamed on the Pakistani Taliban, widely believed to have been helped by militants from Punjab province.

Abbas identified the militant captured Sunday as Aqeel, alias Dr Usman. A security official in Punjab said Usman was believed to be a member of the notorious Lashkar-e-Jhangvi group.
Militants we arrested in Lahore had told us during interrogation that he masterminded the attack on the Sri Lankan team and provided weapons, said the official.

Some hostage takers' phone calls were intercepted and they were speaking Punjabi, another security official said.

VIOLENT WEEK

The attack on the army came at the end of a violent week.

Last Monday, a suicide bomber attacked a U.N. office in Islamabad killing five staff members, and Friday a suspected suicide bomber killed 49 people in Peshawar.

All roads lead to South Waziristan, Interior Minister Rehman Malik said Saturday, referring to all of the attacks. Now the government has no other option but to launch an offensive.

The army has been preparing an offensive with air and artillery attacks but has not said when ground troops will go in.

The United States needs Pakistani help against militants crossing into Afghanistan to fight U.S.-led forces there and has been urging action against Afghan Taliban factions on the border.

In March, militants pushed to within 100 km (60 miles) of Islamabad, sparking grave concern among allies, including the United States, for Pakistan's prospects, and fears for the safety of its nuclear weapons.

In late April, the army launched an offensive in Swat, northwest of Islamabad, and largely cleared out the Taliban.

The militants suffered another big blow on August 5, when their leader, Baitullah Mehsud, was killed in a missile attack by a U.S. drone aircraft. His successor vowed revenge last week.

U.S. Secretary of State Hillary Clinton condemned the Saturday attack and she and British Foreign Secretary David Miliband expressed confidence in the security of Pakistani nuclear facilities.

Washington had every confidence in the government's control over its nuclear weapons, Clinton told a London news conference.

(Reporting by Kamran Haider and Zeeshan Haider in ISLAMABAD, Keith Weir and Jeff Mason in LONDON; Writing by Robert Birsel; Editing by bill Tarrant)