Pakistan's army chief took centre stage in a national political crisis on Thursday night by holding talks with two protest leaders who have been agitating on the streets of Islamabad for the overthrow of the elected government for the last two weeks.
Politician and former cricketer Imran Khan and a Muslim cleric called Tahir-ul-Qadri left their protest camps outside parliament for back-to-back audiences with Raheel Sharif, the general in charge of Pakistan's 500,000-strong army.
Officials said the general had agreed to mediate in a bitter stand-off between the government and Khan and Qadri who have brought thousands of their followers to Islamabad.
Even though prime minister Nawaz Sharif requested the army chief become involved in defusing the crisis, the development was widely seen as a decisive re-assertion of power by an institution that has directly or indirectly ruled Pakistan for most of its history.
The development was widely criticised as a major setback for the country and even described by some as a "soft coup" by the army. One key ally of Khan, a veteran politician called Javed Hashmi, said the army's involvement was a "shameful time for all politicians".
Ayesha Siddiqa, an expert on Pakistan's military, said Sharif would now only be able to serve out the rest of his term as a "ceremonial prime minister".
"Any gains made in the last eight years to strengthen democracy have been rolled back," she said.
Sharif, a politician who lost power during the 1999 military takeover, was elected last year determined to curb the power of the army.
In so doing he enraged the military establishment by ordering the trial of former dictator Pervez Musharraf for treason, pushing for deeper trade ties with arch-enemy India and siding with the country's biggest television station after it accused the army of trying to kill one of its journalists.
On Thursday a senior aide to the prime minister said the army had agreed to help the prime minister defuse the crisis on the condition he left key areas of national affairs to the army, principally foreign and defence policy towards Afghanistan and India.
The aide said among the specific army demands was that Sharif should not call for investigations into firing by Pakistani troops across contested areas of the border with India, of which there has been an upsurge in recent weeks.
The prime minister's reliance on the army chief for survival was underlined by the regular meetings he has had with Sharif in recent days to discuss the crisis.
Some government officials believe the army deliberately encouraged Khan and Qadri to launch their protests to create the circumstances that would allow the army to intervene.
Khan, who has a fondness for cricketing metaphors, has frequently hinted during the two week political drama that a "third umpire" would at some point "raise his finger" and send the prime minister packing.
But it remains unlikely the army will support Khan's demand for the prime minister to be sacked.
Any unconstitutional move would risk billions of dollars of much needed US assistance. Sharif also enjoys solid support in parliament and the quiet endorsement of the US which rejects Khan's claims that Sharif stole last year's election through industrial scale rigging.
In the early hours of Friday morning, after his meeting with Sharif at Army House in the neighbouring city of Rawalpindi, Khan returned to his supporters to insist he would not drop his demand for the prime minister to step down.
"Our sit-in will not be called off until Prime Minister Sharif resigns," he told what remained of the crowd that gathers each night amid a carnival-like atmosphere each night to hear music and speeches.
Khan has watered down his demands somewhat, and now calls for Sharif to temporarily step down as prime minister whilst a judicial inquiry investigates claims of electoral fraud.
Qadri, a Barelvi cleric who spends most of his time in Canada, has also narrowed his focus. Although he wants to sweep away Pakistan's democratic system which he says is irremediably corrupt in recent days his demands have centred on a murder inquiry into the killing of his supporters in June.
At least 10 people died during clashes in the city of Lahore after police attempted to remove security barriers near Qadri's office.
On Thursday, in an apparent bid to appease Qadri, the prime minister's office said a murder case had been registered against senior government officials including Sharif.
The inquiry may ultimately force Sharif's younger brother Shahbaz to resign from his powerful position as chief minister of Punjab province.