At least eleven people have been killed in a suspected suicide bombing near Pakistan's Red Mosque, following clashes between Islamists and police.
"Most of the dead were policemen," a security official said. More than 40 people were injured.
Torn police uniforms lay about the scene in Islamabad while blood stained the streets, a BBC correspondent said.
The mosque was the scene of a bloody siege that ended earlier in July with the deaths of more than 100 people.
A protest grew on Friday as students demanded the return of the mosque's surviving pro-Taleban cleric, Abdul Aziz, who is in detention.
Security forces initially stood by as the protest began, but later dozens of police officers in full riot gear were deployed.
Armoured riot vehicles confronted the protesters, some of whom carried wooden staves or hurled rocks at police. Tear gas was fired in return.
The protesters defaced the mosque, which had been repainted in pale colours by the authorities after the end of the siege.
They wrote "Red Mosque" in large Urdu script on the dome of the building. They also raised a black flag with two crossed swords - meant to symbolise jihad, or holy war.
Earlier protesters had prevented a government-appointed cleric from leading Friday prayers at what was supposed to be the peaceful re-opening of the mosque.
"I was told everything would be peaceful. I was never interested in taking up this job and after today I will never do it," Mohammad Ashfaq told AFP news agency as he left the mosque with a police escort.
The explosion took place soon after the protests were subdued by police, said the BBC's Dan Isaacs, who was only a short distance away.
It appeared to be targeted at the police cordon arranged round the mosque, where dozens of officers were lined up, he said.
A security official told the AFP news agency the bomb was set off by a suicide attacker, although our correspondent was unable to confirm this.
"A man detonated explosives strapped to his body among two rows of Punjab police constabulary members who were there on duty because of the unrest at the Red Mosque," he said.
One official said seven police officers were among the dead.
Centre of radicalism
Such a high-profile attack in the heart of the Pakistani capital will be extremely worrying for Pakistan's President Pervez Musharraf, who is under increasing political pressure and facing rising violence by militants, our correspondent says.
Less than three weeks ago, troops stormed the mosque after its clerics and students waged an increasingly aggressive campaign to enforce strict Sharia law in Islamabad.
The mosque had become a centre of radical Islamic learning and housed several thousand male and female students in adjacent seminaries.
Protesters daubed the mosque with graffiti
The chief of Dyala prison in Rawalpindi told Pakistan's Supreme Court that 567 of the 620 students detained during the siege and 36-hour battle had been freed. Of those still being held, three are women.
A legal aid committee says it has received 58 complaints from relatives about men who are said to be missing following the siege.
More than 100 people were killed in the siege including 11 soldiers and an as yet unknown number of extremists and their hostages.
The attack on the mosque was the fiercest battle fought by security forces in mainland Pakistan since President Musharraf vowed to dismantle the militant jihadi network in the country in the aftermath of the 11 September 2001 attacks on the US.