By Aamer Ahmed Khan
BBC Urdu Service, Islamabad
Barely two weeks ago, Pakistan's military ruler, General Pervez Musharraf, was battling for his political survival.
Musharraf is at a make-or-break phase in his eighth year in power
The war drums being beaten by the opposition at home were reaching a crescendo.
His battle with the country's chief justice had taken a serious toll on his image as a military man who loathes the pettiness of everyday politics.
More importantly, perhaps, his Western allies seemed to be getting increasingly impatient with his seeming inability to deal decisively with Islamist extremists.
All this seems to have changed dramatically over the last three days, after Gen Musharraf gave his administration the green light for dismantling a radical seminary located in the heart of capital, Islamabad.
Jamia Hafsa - a seminary affiliated with one of the city's oldest mosques, known as the Red Mosque - had been running circles around the Islamabad administration since the beginning of this year.
Demanding strict enforcement of Sharia (Islamic law), Red Mosque clerics had let loose moral squads on the capital to "prevent vices and promote virtue" - a concept first institutionalised by the Taleban in Afghanistan.
These moral squads, consisting of armed male and female students, were going around the city threatening music shop owners, and kidnapping women over allegations of operating brothels.
But every time they took the law into their own hands, the government had opted for negotiations, arguing that any use of force was likely to lead to bloodshed.
Emboldened by the government's perceived pussy-footing, Red Mosque clerics kept raising their public profile until they became a major embarrassment for the government.
However, President Musharraf kept advocating restraint on the basis of intelligence reports which warned of the presence of a large number of suicide bombers inside the mosque and its affiliated seminary.
Concern in the West
The president repeatedly said if the government tried to use force, the clerics would unleash suicide bombers who could kill dozens.
"The same people including the media who are currently demanding that the government take action will then turn around and start accusing the government of killing its own people," he said at one of his public appearances earlier this year.
Musharraf's opponents accuse him of being soft on Islamist radicals
"I will order action if the media promises it will not show dead bodies," he said on another occasion.
Initially, many agreed with the president's reasoning, but the argument started to lose weight as the Red Mosque clerics became bolder.
"The turning point clearly was the abduction of the Chinese massage parlour girls," says a senior diplomat in Islamabad.
"We know that the Chinese sent a very strong message that they could take losses in Balochistan or the tribal belt but were not prepared to see their citizens abducted and tortured bang in the heart of the capital."
Meanwhile, President Musharraf's opponents were having a field day. The Red Mosque provided great support for their allegation against the president that he wasn't sincere in battling extremism in Pakistan.
Increased attacks in Afghanistan by Pakistan-based Taleban in the first six months of the year had also started to cause concern in Western capitals.
The influential British and American media had started to revisit skeletons that President Musharraf had worked so hard to bury.
Throughout its history, Pakistan has been known to pursue various strands of its foreign policy agenda through the use of private militias.
Thousands of Pakistan-based Islamist militants have fought against the Soviets in Afghanistan.
Pakistan's proxy war with India over the disputed territory of Kashmir was fought almost exclusively through militant Islamist organisations.
This is a big reason why President Musharraf's opponents have consistently accused him of being soft on Islamist radicals because they have historically worked closely with the army and are generally regarded as vital parts of the country's foreign policy agenda.
More recently, secular opposition parties in Pakistan have accused President Musharraf of stoking Islamist radicalism in order to keep the secular groups in check.
The Red Mosque situation had become the primary fuel with which the opposition was hoping to ignite anti-Musharraf sentiments both at home and abroad.
President Musharraf must have been aware of the ire the Red Mosque was stoking up against him when he chose to move.
Senior officials in the government say he feared serious bloodshed but was prepared to risk it.
Make or break
Often described as one of the most embattled rulers in the country's history, President Musharraf was clearly desperate for a success that could work for him both at home and abroad.
And as the Red Mosque brigade started to crumble against a determined siege by the security forces, President Musharraf must have taken several deep breaths laden with the scent of political success.
Senior officials say he is now planning to address the nation soon after the Red Mosque saga comes to a close.
It doesn't take much to guess what he will say.
As the nation inches closer to elections later in the year and a decision from General Musharraf on his dual role as president and army chief, he will be focusing all his energies on getting just one message across: He is still the West's best bet against radical Islam who can move decisively as and when needed.
Whatever the level of truth or reality in this assertion, it is a political reality he is desperate to create as he heads for a make-or-break phase in his eighth year in power.