ISLAMABAD - A suicide bomber attacked a police building in Pakistan's capital Saturday, blowing himself up in a courtyard after being shot by officers as he ran toward them, officials said. Two officers died and six were wounded.

The bombing in Islamabad was the latest in a string of attacks in Pakistani cities that officials blame on militants taking revenge for the military's month-old offensive to oust the Taliban from the Swat Valley in the country's northwest.

Waquar Shah, an officer on duty at the police emergency call centre when it was attacked, said a man wearing a heavy jacket was spotted as he jumped over a wall at the centre into a courtyard.

"He jumped in from the rear wall, then ran toward the offices," Shah said. "One of our guys opened fire on him and he fell and blew up."

Senior police commander Tahir Aalam said two officers were killed and six others were injured.

Earlier Saturday, militants ambushed a military convoy in a district near Swat, killing two detained aides of a senior cleric with close ties to the Taliban, the army said.

It was not clear if the attack was an attempt to rescue the prisoners or assassinate them before they could provide intelligence to the military -- or even if the attackers knew that Taliban-linked prisoners were in the convoy.

A roadside bomb and gunfire hit the convoy before dawn as it travelled from Sakhakot town near Swat to the main northwestern city of Peshawar, the army said. One soldier also died in the attack and five were wounded.

The army identified the prisoners as Muhammad Maulana Alam and Ameer Izzat Khan, top aides to hardline cleric Sufi Muhammad, who is the father-in-law of Maulana Fazlullah, the Taliban chief in Swat.

Sufi Muhammad negotiated a peace deal with the government that was widely seen as allowing the Taliban to take control of the valley.

The deal collapsed earlier this year when the Taliban advanced into neighbouring districts, triggering a military offensive that prompted a spree of retaliatory attacks by militants in the northwest and beyond.

"These two were being transported so that intelligence agencies could investigate them," military spokesman Maj.-Gen. Athar Abbas told reporters.

No motive was known, but "I wouldn't rule out that they were targeted or killed on purpose," Abbas said.

The offensive in Swat is seen as a test of Pakistan's resolve to take on militants who have challenged the central government's rule by strengthening their influence in the border region with Afghanistan.

More than 1,300 militants and 105 soldiers have died so far, Abbas said, but he conceded there were few senior Taliban leaders among the dead.