Gunmen opened fire at a mosque close to Pakistan's army headquarters during Friday prayers before blowing themselves up, killing at least 36 people, including six military officers.
An intelligence official said 70 others were wounded in Friday's suicide bombing, which occurred in the city of Rawalpindi, just a few kilometres outside the capital of Islamabad.
The official spoke on condition of anonymity because he was not allowed to speak to the media on the record.
A local television station reported the Pakistani Taliban had claimed responsibility.
A military statement said four attackers hurled grenades and then opened fire as they rushed toward the mosque located on Parade Lane in a military residential colony, just a few kilometres from the capital.
Two suicide bombers then blew themselves up inside, while the other two militants were killed in an exchange of gunfire, the statement said.
Military officials killed
Among those killed were a major-general, a brigadier, two lieutenant colonels, one major and a retired major as well as three regular soldiers, military spokesman Maj.-Gen. Athar Abbas said.
The attack began when attackers staged an explosion at a checkpoint at an army installation near the military headquarters in Rawalpindi.
Witnesses said the attackers entered the mosque carrying hand grenades, automatic weapons and ammunition belts slung around their shoulders, and opened fire on the 200 worshippers.
Nasir Ali Sheikh said he saw the attackers as he walked there to pray and witnessed the attack.
"They were killing people like animals," he said. "I couldn't understand what was happening."
The attack was the third in the city of Rawalpindi in nearly two months, and the latest in a wave of violence since the country launched an offensive in mid-October against Taliban militants in the restive area of South Waziristan near the border with Afghanistan.
Officials estimate militant attacks have killed as many as 400 people since October.