In a daring midday raid that showed insurgents’ ability to strike the Pakistani military virtually at will, militants Friday stormed a Rawalpindi mosque filled with military officers and their children, killing at least 37 people with a deadly combination of gunfire, grenades and suicide bomb blasts.

The attack, which also injured at least 86 people, was the latest in a series of devastating terrorist strikes meant as retaliation for the Pakistani military’s assault on Taliban strongholds in South Waziristan and other tribal areas along the nation’s border with Afghanistan.

The dead included 27 civilians, 17 of them children, said army spokesman Maj. Gen. Athar Abbas.

The government asserts that it has uprooted Taliban fighters from most of South Waziristan, but military commanders acknowledge that troops have killed only about 600 of the estimated 10,000 militants based in the largely ungoverned tribal region.

Most of the militants and their leaders have fled to other tribal districts along the Afghan border. In the meantime, militants have carried out suicide attacks and commando-style raids across Pakistan in an attempt to erode popular support for the military’s operations.

Since early October, more than 400 people have been killed in those attacks. As with the attack Friday in Rawalpindi, the targets have often been the armed forces, police and intelligence agency installations, or places where military officers are known to gather.

The boldest of those strikes occurred Oct. 10 in Rawalpindi at the army’s headquarters, a sprawling, heavily guarded complex that is the military’s nerve center. Militants shot their way through checkpoints and held 42 officers and civilian employees hostage in one of the buildings. The 22-hour standoff ended when Pakistani commandos killed nine of the militants and arrested their leader, but the raid also left 14 military officers and civilian workers dead.

The latest attack in Rawalpindi appeared to be timed to cause maximum carnage. It occurred on a Friday afternoon, when Muslims traditionally head to mosques for a special weekly prayer.

Shortly before 1:40 p.m., four militants converged on the Parade Lane Mosque, the primary place of worship for retired and active military officers who live in the surrounding Qasim Market neighborhood. The mosque is next to an army parade ground, and is about a five-minute drive from the Pakistani army’s headquarters.

Army officials said the militants did not try to enter the mosque through a heavily secured main gate. They may have scaled a boundary wall to get onto the grounds, one official said, though investigators are still looking into how the militants were able to breach the mosque’s security.

“The area is a high-security zone,” Abbas, the army spokesman, told Dawn news channel. “But it is yet to be established where the breach took place. It appears definitely there was a security breach somewhere.”

Two of the militants entered the mosque, which was filled with about 200 worshipers, army officials said. The mosque is usually restricted to active and retired military personnel and their families.

The militants inside the mosque lobbed grenades at the worshipers while the other two outside sprayed the room with gunfire, army officials said. Then the two militants inside detonated the explosives vests they were wearing.

The two militants outside exchanged gunfire with security forces. The crossfire kept rescue workers from getting into the building, said Abdur Rehman, chief of Rawalpindi’s emergency rescue agency.

Once the gunfire subsided, Rehman went into the mosque.

“I saw so many dead bodies,” he said. “There were charred body parts on the floor, and huge amounts of blood. It was a terrible scene.”

Police and soldiers cordoned off the neighborhood, while military helicopters hovered overhead. By late afternoon, army officials said, the other two militants were dead, though they did not say whether security forces shot them or whether they had killed themselves.

Abbas said the 10 military personnel slain were a major general, two lieutenant colonels, a colonel, two majors, another officer and three soldiers. Among the injured was Muhammad Yousuf, a former vice chief army commander during Gen. Pervez Musharraf’s rule.

Friday’s attack was the 15th major terrorist strike in Pakistan since Oct. 17, when the government sent 30,000 troops into South Waziristan to quell the Pakistani Taliban. This week, a suicide bomber killed two people outside the navy headquarters in Islamabad, the Pakistani capital.

Abbas said that as the Pakistani military has advanced on Taliban strongholds in the Waziristan region, the militant group has nurtured sleeper cells in the country’s densely populated cities that are difficult to ferret out, largely because the militants are able to easily blend in.

“They’re in the pipeline, and they’re probably going to conduct such attacks,” Abbas said. “So these are the last acts of this organization, desperate acts. We’ll have to see and absorb a few more like that.”

alex.rodriguez@latimes.com