Years later, the mosque itself became a battlefield in an eight-day siege and firefight in July 2007 that pitted soldiers against militants and students holed up inside, and ended with more than 100 deaths. It was a turning point for Pakistan - a sign that Islamist militancy, a long-favored strategic tool for the Pakistani military, had become a pressing threat to the government and the country's biggest cities.
Now the Red Mosque is again back in the public eye, at a crucial moment in a national debate over whether to negotiate with militants, as the government is struggling to do, or to fight them more robustly.
The chief cleric of the Red Mosque, Maulana Abdul Aziz, has inserted himself into the argument with a typically showy gesture: the inauguration of a new library named after the slain founder of al-Qaida.
"If Pakistan truly has freedom of expression, then we should be able to express our love for our heroes," said Aziz, a willowy, bespectacled man with a wiry gray beard, in a room with the sign "Martyr Osama bin Laden Library" on the door. "And we love Osama bin Laden."
But the Red Mosque's resurgence is about more than publicity stunts. As a jihadi brand, it has burnished its credentials as a citadel of Islamist revolt. And, just as they did seven years ago, the mosque's clerics are exploiting the government's failure to offer an alternative vision of Pakistan's future.
"We need a strong counternarrative, something that gives purpose to the war against the Taliban," said Pervez Hoodbhoy, a Pakistani physics professor and outspoken critic of religious fundamentalism. "But that is lacking. And while people criticize the Taliban for their tactics, many believe their hearts are in the right place because they are fighting for Islam."
Today, Aziz delivers thunderous Friday sermons from the lavishly refurbished Red Mosque, a stone's throw from the parliament building. And he oversees a network of madrasas that teach 5,000 students.
Only seven years ago, the mosque was in the throes of a pitched battle against the authorities. Aziz tried to escape the siege under the cover of a burqa, a purse clutched in his gloved hands, but was captured and paraded by the intelligence services on national television, still wearing the black cloak.
The cleric's brother, Abdul Rashid Ghazi, and his elderly mother died in the firefight. After the siege was over, Aziz was charged with murder, abduction, arson and terrorism. Yet within a couple of years, the mosque and Aziz were back in business.
Malik Riaz Hussain, a sympathetic property tycoon, provided a temporary home for hundreds of madrasa students, and spent at least $150,000 on refurbishing the bullet-pocked mosque. He attributed his generosity to pragmatism rather than religious conviction.
"I have huge interests in Islamabad and Rawalpindi," the businessman, who has close ties to the military, told The New York Times in a 2010 interview. "Bad law and order is bad for my business."
The city provided land worth millions of dollars in central Islamabad for the rebuilding of Jamia Hafsa, a women's madrasa that had been bulldozed after the 2007 siege. The madrasa, whose construction is not complete, is home to the Osama bin Laden library.
But it is the courts that have been most indulgent toward Aziz and his followers. Over the past year, judges have dismissed all of the 27 criminal charges against Aziz, who at times has used the courtroom as a pulpit to call for the imposition of Shariah law.
Instead, the court's attention has mostly focused on Gen. Pervez Musharraf, Pakistan's former military ruler. A judicial inquest determined that Musharraf, not Aziz, was responsible for the deaths during the siege of the Red Mosque, even though armed jihadis from banned militant groups had joined the students inside.
In October, a senior judge, prompted by Aziz's lawyers, charged Musharraf for his role in the siege and placed him under house arrest. In recent weeks the Martyrs Foundation, a group that represents the families of students who died in the siege, petitioned the Supreme Court to prevent Musharraf from leaving Pakistan until the completion of his treason trial, underway now.
"It's a realization of our deepest fears that right-wing forces will take over the country, piece by piece," said Hoodbhoy, who recently founded a think tank to stimulate the debate. "Not only is the Red Mosque in better shape than before the siege, it proudly flouts the fact that its students faced up to the government forces and defeated them."
The police, however, are more skeptical of Aziz. In a recent court hearing, the Islamabad police chief argued that the cleric's name should remain on an official schedule of suspected terrorists for his longstanding links to Sipah-e-Sahaba Pakistan, a sectarian militant group known for violence against Shiite Muslims.
At the Bin Laden library, Aziz offered a qualified denunciation of violence - it was justified only in self-defense, he said - and denied accusations that his reverential gesture toward the onetime enemy of America was a publicity stunt.
"A majority of Pakistani people love Osama bin Laden," he said.
Opinion polls do not support that assertion, but it is true that many Pakistanis - torn among Taliban violence, anger toward America and continued uncertainty about the place of Islam - harbor ambiguous feelings toward bin Laden.
And names do matter. Away from Islamist violence, the naming of public buildings has become contested ground in the struggle between Islamists and democrats.
Islamabad's main airport, for example, is named after Benazir Bhutto, the opposition leader who was killed by militants in late 2007. A few miles away a new mosque honors Malik Mumtaz Hussain Qadri, the extremist who in 2011 gunned down Salman Taseer, the Punjab governor and crusader against the country's harsh anti-blasphemy laws.
At Jamia Hafsa, Aziz has named a dispensary after Aafia Siddiqui, a Pakistani woman who is serving an 86-year prison term in the United States on charges of attempting to kill a U.S. soldier and an FBI official in Afghanistan.
Whatever its direct ties to militancy, the Red Mosque remains a powerful battle cry for extremists. The nominal leader of al-Qaida, Ayman al-Zawahri, has issued statements in support of the Red Mosque, while former students have carried out bomb attacks on Westerners and Pakistanis.
The Red Mosque has also staged a comeback on the Internet: Its Facebook page is named after the 313 Brigade, a fearsome band of armed female students that conducted raids on suspected brothels and video stores in Islamabad in 2007, in the months before the siege.
A return to such vigilantism is unlikely, said Cyril Almeida, a columnist with Dawn, an English-language newspaper in Pakistan. But he warned that the mosque's enhanced profile posed other dangers.
"The more they gain visibility on the national stage, the more the myth of militants fighting the good fight against an illegitimate state gains in strength," he said. "And that makes the narrative war more difficult for the state to win."
Early this year, the government inducted Aziz into the talks with the Taliban, hoping to use him as a militant interlocutor. But in February the cleric abandoned the process. No talks are possible, he said at a news conference, before Shariah law replaces Pakistan's Constitution.