Pakistani security personnel keep guard outside the Supreme Court building during a hearing for Prime Minister Yousuf Raza Gilani. Despite recent turmoil and Pakistani media predications, a military coup d’etat has not occurred. (Aamir Qureshi/AFP/Getty Images)

Just days ago, the rumblings of a familiar process seemed underway in Pakistan: The squeezed civilian government berated the looming military. The army darkly warned of consequences. A new general assumed control of a brigade known for helping to oust past governments. The president flew overseas.

A coup d’etat was coming, the Pakistani media screamed. Except that it did not.

Instead, Pakistan again defaulted to what is also becoming a familiar ritual. Having survived the forecast collapse, the government lurched closer to becoming the first-ever elected regime to finish its term. And public debate ensued about whether Pakistan is witnessing a veiled military power grab — or whether this coup-prone nation’s nascent democracy might be growing real roots.

“There is an enlarged democratic space,” said Raza Rumi, a newspaper columnist who counts himself among the optimists. “So this is an interesting moment. The government may or may not survive . . . but the assertion of the civilians is inspiring.”

The current political crises, involving a memo scandal and graft allegations, feature elements that have helped bring down previous civilian governments: avaricious politicians, baying opposition parties, pliant judges and a failing economy that is said to worry the generals.

But many analysts say the tools of past coups, such as tanks and state media blackouts, could not work in today’s Pakistan, where the news media and the judiciary have emerged as new power centers. That has given Prime Minister Yousuf Raza Gilani and President Asif Ali Zardari surprising confidence to publicly challenge the army in what feels like a heavily watched bluffing game. One senior official in the ruling Pakistan People’s Party, speaking on the condition of anonymity because of the sensitivity of the matter, confidently said the party does not “see the chances of direct army intervention.”

The military, for starters, has its own problems. Gen. Ashfaq Kayani, chief of the Army, has strived to restore the armed forces’ public image since a decade of military rule ended in 2008, but it has faced unprecedented domestic criticism after the U.S. raid to kill Osama bin Laden. A resilient Islamist insurgency leaves generals little down time to manage the economy, said one military official, who spoke on the condition of anonymity because the official was not authorized to discuss the matter publicly.

“The military is so overstretched and preoccupied fighting the militants,” said retired Lt. Gen. Talat Masood, a prominent defense analyst. “It’s a full-time occupation.”

Influence today is spread more widely than in past eras, analysts say. In recent years, Pakistan has sprouted a slew of sensationalist and scrappy news outlets that, while generally rabidly anti-government, would be reluctant to endorse a uniformed regime that could corral their reach and profits. Parliament has become less deferential to the military, and the main opposition party, led by Nawaz Sharif, is no friend of the army, which overthrew him in 1999.

The main coup deterrent, some argue, is an emboldened Supreme Court, which has assumed an activist, almost messianic public role. Like the media and the army, it has displayed clear antipathy toward the government by keenly pursuing alleged corruption cases. Those include dated money laundering allegations against Zardari, over which the court has threatened to dismiss Gilani.

But the court was also restored after a struggle against Gen. Pervez Musharraf, the former dictator, and appears unlikely to give legal blessing to a military takeover.

“This was not the case before. The courts were very happy and eager to play along with dictators,” Rumi said.

There are far gloomier analyses about the new roles of the media and the Supreme Court. Pakistani intelligence is widely believed to plant anti-government stories in the news media and intimidate journalists to prevent coverage that is critical of the military.

The court’s laser focus on government misdeeds — driven, its backers say, by a desire to return looted funds to public coffers — has led to accusations that it is doing the bidding of the military and carrying out a “judicial coup.” It is cheered on by Sharif’s opposition party, whose leaders have largely escaped the court’s scrutiny, as has the military.

Against that backdrop, some say the absence of military intervention is irrelevant. The government, hounded by the news media and courts, has been stuck in survival mode since day one, said Ayesha Siddiqa, a military analyst.

“People ask me if I think this government will complete its term. I say it’s immaterial now if it does or it doesn’t, because it has been made absolutely redundant,” Siddiqa said.

That the debate swirling here centers on a “clash of institutions” underscores the dysfunction Pakistan’s democratic setup: The army is a branch of the government that, officially, answers to Zardari. In practice, it has long maintained a grip over foreign and security policies — including some, such as the sponsorship of anti-India jihadist fighters, that have come to haunt Pakistan.

In its bid to survive, the government has spent three years doing little to challenge this arrangement. But it has lashed out recently, with Gilani issuing statements that count here as perilously provocative: Last month, the prime minister warned of a “state within a state” and questioned what kind of visa allowed bin Laden to live in Pakistan for years — a clear dig at the failure of Pakistani intelligence to identify the whereabouts of the world’s most wanted man.

In the bizarre chess match that the duel has become, some analysts and Pakistan People’s Party members say an outright coup would be the party’s preference. That would allow the party to cast itself as a martyr, a role it has cultivated over many years of battle with the military.

But as the government continues to duke it out with the army and the courts, the civilian leadership risks losing the tolerance of the public. For ordinary Pakistanis, the main concerns are rising prices, power shortages, unemployment and violence, which get scant attention in the halls of power.

For now, Gilani and Zardari seem to be betting on the generosity of people such as Arif Hayat, a civil engineer who took a break on a recent morning from shopping at an Islamabad market to practically spit insults about the government.

That civilian government, Hayat said, remains “not democratic,” unconcerned about ordinary Pakistanis and “only here to plunder.” But, he said, military rule is an unsavory alternative.

“It is only democracy that can change this country,” Hayat, 41, said “All the previous military rulers badly failed and created more problems for us.”

Special correspondent Shaiq Hussain contributed to this report.