Pakistan's Supreme Court ordered the arrest of the prime minister on Tuesday on corruption allegations, ratcheting up pressure on a government that is also facing street protests led by a cleric who has a history of ties to the army.
The combination of the arrest order and the mass protest in the capital, Islamabad, led by Muslim cleric Muhammad Tahirul Qadri, raised fears among politicians that the military was working with the judiciary to force out a civilian leader.
"There is no doubt that Qadri's march and the Supreme Court's verdict were masterminded by the military establishment of Pakistan," Fawad Chaudhry, an aide to Prime Minister Raja Pervez Ashraf, told Reuters.
"The military can intervene at this moment as the Supreme Court has opened a way for it."
However, the ruling coalition led by the Pakistan Peoples Party (PPP) has a majority in parliament and lawmakers can simply elect another prime minister if Ashraf is ousted. In June, Ashraf replaced Prime Minister Yusuf Raza Gilani, who was disqualified by the Supreme Court in a previous showdown between the government and the judiciary.
Elections are due in a few months and President Asif Ali Zardari hopes to lead the first civilian government in Pakistan's 65 years as an independent nation that will complete its full term.
But power struggles will distract the unpopular government from tackling an array of problems - a Taliban insurgency, economic stagnation and growing sectarian tensions triggered by bomb attacks and tit-for-tat shootings.
The military, which sees itself as the guarantor of Pakistan's stability, has long regarded the PPP-led government as corrupt, incompetent and unable to prevent the nuclear-armed country from falling apart.
Pakistan's powerful army has a long history of coups and intervening in politics. But these days, generals seem to have little appetite for a coup. Army chief General Ashfaq Kayani has vowed to keep the military out of politics.
But many believe top military leaders still try to exert behind-the-scenes influence, and any moves by the military in the latest crisis could not happen without a green light from Kayani, arguably the most powerful man in Pakistan.
"Extra-constitutional regime change, or 'outside of the political calendar' if you will, is only possible in Pakistan with the tacit nod of the military, on account of it being a long-time stakeholder in Pakistani politics," said Shamila Chaudhry, an analyst at Eurasia Group.
"The Qadri march was like a trial balloon. The military indirectly sent it out to see if it would work."
Some politicians believe the military will try to dominate the caretaker administration that will oversee the run-up to the polls after parliament is dissolved, which is due to happen in March. An election date has yet to be announced.
The protest by Qadri and his followers has also been seen by commentators as being orchestrated by the military to add to the pressure on Zardari's government, although the military has denied any ties to the cleric.
Thousands of followers of the populist cleric camped near the federal parliament cheered and waved Pakistani flags as television channels broadcast news of the Supreme Court's order to arrest Ashraf on charges of corruption.
"We don't want any of those old politicians. They just take all the people's money," said 19-year-old student Mohammed Wasim. "We congratulate the whole nation (on the Supreme Court's order). Now we have to take the rest of the thieves to court."
Government officials said they were baffled by the arrest order, which came hours after Chief Justice Iftikhar Chaudhry said elections should go ahead as scheduled.
"This was totally unexpected," an official in Ashraf's office told Reuters. "The prime minister and two or three of his friends were watching Qadri speak on television and this suddenly happened."
Pakistan's stock exchange fell by more than 500 points, or nearly 3 percent, on news of the court order, due to fears over fresh political turmoil, which comes against a backdrop of militant bombings and tension on the border with India.
Qadri, who played a role in backing a military coup in 1999, threatened to remain camped out near the federal parliament with thousands of supporters until his demands for the resignation of the government were met.
The fiery orator returned home from Canada less than a month ago to lead a call for electoral reforms to bar corrupt politicians from office, which has made him an instant hit among Pakistanis disillusioned with the state.
In a speech from behind a bullet-proof shield in front of parliament, Qadri praised the military and the judiciary, the country's two other power centres.
"(The government) has wasted and brought a bad end to our armed forces, those armed forces who are highly sincere, highly competent and highly capable and highly professional," he said, alternating between Urdu and English.
"Even they can't do anything because the political government isn't able to deliver anything from this land. Judgments are being passed by our great, independent judiciary but the government is not ready to implement them."
Qadri is demanding that the government dissolve the legislature and announce the formation of a caretaker government to oversee the run-up to elections.
One senior military officer, who said he was speaking in a purely personal capacity, said there was no appetite in the military to repeat the coups seen in Pakistan's past, but added the stand-off could be resolved if the army played a role in the formation of a caretaker government as a "moderator."
"We should try as far as possible to abide by the constitution and law in looking for change. The army chief has made this clear," the officer told Reuters.
"But things seem to be moving beyond control," the officer added. "It is totally incorrect to say the army is behind Qadri. But if he brings thousands of people to the streets and things get worse, there may be very few options."
The United States, a major aid donor despite strained ties with Pakistan in recent years, said it was up to the Pakistanis to resolve their political differences, but stressed its support for democratic rule.
"That's an internal issue for Pakistanis to resolve, as long as it is resolved in a just and transparent manner that protects the constitution, protects the rule of law," State Department spokeswoman Victoria Nuland told reporters in Washington. "We stand strongly in favor of a democratically elected civilian government in Pakistan, and we'll continue to do so."