For much of Pakistan's independent existence, the country's politics have been dominated by its powerful military. The generals have a long history of interrupting and meddling with civilian rule. The election last year of Prime Minister Nawaz Sharif marked the first time in almost seven decades that Pakistan was able to carry out a peaceful transfer of power between civilian governments.

But the specter of the army now looms large once more. In order to placate heated protests against his rule, Sharif agreed this week to mediation by the army, an institution that is respected by a vast cross-section of society. Pakistan's army chief, Raheel Sharif (who is not related to the prime minister), conducted meetings with the two main protest leaders--the maverick politician Imran Khan and fiery preacher Tahirul Qadri, both of whom have led noisy protest movements this past month and are seeking the collapse of Sharif's government.

But, in return for its intervention, it appears the military has exacted a price from Prime Minister Sharif. According to reports, he has agreed to cede control of aspects of the country's security and foreign policy to the military. It's a difficult situation for Sharif: In 1999, then in his second term as prime minister, he was ousted by a military coup led by then Gen. Pervez Musharraf. Now, the military, in a sense, is once more showing the prime minister who is boss.

"If Nawaz Sharif survives, for the rest of his term, he will be a ceremonial prime minister—the world will not take him seriously," said Ayesha Siddiqa, an Islamabad-based analyst told the Wall Street Journal. "A soft coup has already taken place. The question is whether it will harden."

Since returning to power last year, Sharif's efforts to both punish Musharraf -- who currently awaits trial -- and entrench civilian power have angered members of the top brass. Sharif also sought to improve ties with India. The Pakistani military, a sprawling institution with its own business concerns and a half a million-strong standing army, finds something of a raison d'etre in its historic rivalry with India. The countries have fought four wars since their independence from Britain in 1947. "If Pakistan and India become normal neighbors," writes Pakistani analyst Mosharraf Zaidi, "the military's influence in Pakistan automatically decreases. The hawks clearly won't go easily."

There are many good reasons, as Zaidi points out, to criticize Sharif, particularly for the "rank incompetence" of his government's decision-making. "He is hamstrung by an obsession with surrounding himself with loyal but inept advisors and bureaucrats," writes Zaidi.

The protest movements led by Khan and Qadri, as WorldViews explained here, are products of political opportunism animated by genuine grievances with the status quo. Khan, a flashy former cricketer turned rabble-rousing politico, claims Sharif benefited from vote-rigging in the 2013 elections and wants the current government scrapped and new elections held. Most independent observers say what irregularities there were would not have likely changed the outcome. Qadri, meanwhile, who spends much of his time in Canada, has a devoted following at home that has embraced his call for a wholesale transformation of the nature of Pakistani democracy.

Khan and Qadri's supporters have massed in their thousands in Islamabad over the past two weeks. Despite their relatively small numbers and Khan's declining popularity, the protests have seemingly paralyzed the country's politics. Pakistani journalist and author Raza Rumi explains:

Such political instability is not new to Pakistan. A lack of consensus on how the country has to be governed has plagued Pakistan's history with cyclical patterns of military rule and weak civilian governments. With the current protests, such schisms have captured public imagination through a powerful electronic media where the very rationale of democracy is being debated often in an adverse manner. The protests are unique for they are being televised into the homes of millions of Pakistanis and thus creating a broader impact.

Sharif still commands a comfortable majority in parliament and decent levels of popular support as a prime minister. Yet his hold on power looks weak. Tim Craig, The Washington Post's Pakistan bureau chief, writes into WorldViews:

Sharif may be paralyzed due to the lingering trauma he feels after he was dragged out of the prime minster’s residence by the army when Musharraf ousted him in a coup in 1999. Sharif was humiliated.
And to this day, he often appears too nervous and too cautious when confronted with crisis. If he had, for example, just allowed Khan and Qadri to hold a demonstration in front of parliament instead of initially stacking shipping containers to keep them away, there would have been no media drama last week when supporters  of two men stormed  past government defenses.
It would have just been another anti-government protest in country where such demonstrations  are common.
But Sharif instead appeared defensive and isolated. He locked himself up in his house -- without an effective public relations strategy for overcoming Khan’s charm or Qadri’s forcefulness. And now Sharif appears weak and ineffective. And a leader who appears weak in a country as tough as Pakistan is not likely to last long.

No one is really anticipating a fully military takeover, though. As Zaidi notes, the army may retain "a greater say in issues such as the country’s policy toward neighboring India or Afghanistan or the ongoing war against the Pakistani Taliban." But it has little desire to own the systemic problems that have led to popular discontent, such as Pakistan's woeful energy shortages and the challenges facing its stagnant economy.

"Pakistani democracy under Sharif will continue to muddle along as it has in the past," concludes Zaid. But "this crisis is unquestionably a setback for democrats."