Last week, as tens of thousands of protesters advanced on the Pakistani capital to demand his resignation, Sharif dispatched two emissaries to consult with the army chief.
He wanted to know if the military was quietly engineering the twin protest movements by cricket star-turned-politician Imran Khan and activist cleric Tahir ul-Qadri, or if, perhaps, it was preparing to stage a coup.
According to a government insider with a first-hand account of the meeting, Sharif's envoys returned with good news and bad: there will be no coup but if he wants his government to survive, from now on it will have to share space with the army.
The army's media wing declined to comment on the meeting.
Thousands of protesters marched to parliament on Tuesday, using a crane and bolt cutters to force their way past barricades of shipping containers, as riot police and paramilitaries watched on after being told not to intervene.
Military spokesman General Asim Bajwa tweeted a reminder to protesters to respect government institutions and called for "meaningful dialogue" to resolve the crisis.
Even if, as seems likely, the Khan and Qadri protests eventually fizzle out due to a lack of overt support from the military, the prime minister will emerge weakened from the crisis in coup-prone Pakistan.
Sharif may have to be subservient to the generals on issues he wanted to handle himself - from the fight against the Taliban to relations with arch foe India and Pakistan's role in neighbouring, post-NATO Afghanistan.
"The biggest loser will be Nawaz, cut down to size both by puny political rivals and the powerful army," said a government minister who asked not to be named. "From this moment on, he'll always be looking over his shoulder."
A year ago, few would have predicted that Sharif would be in such trouble: back then, he had just swept to power for a third time in a milestone poll that marked nuclear-armed Pakistan's first transition from one elected government to another.
But in the months that followed, Sharif - who had crossed swords with the army in the past - moved to enhance the clout of the civilian government in a country that has been ruled by the military for more than half of its turbulent history.
He irked the generals by putting former military head Pervez Musharraf, who had ended Sharif's last stint as prime minister in a 1999 coup, on trial for treason.
Sharif also opposed a military offensive to crush Taliban insurgents, sided with a media group that had accused the military of shooting one of its journalists and sought reconciliation with India, the perceived threat that the army uses to justify its huge budget and national importance.
INDIA RAPPROCHEMENT AT RISK
Sources in Sharif's government said that, with civilian-military relations in such bad shape, Sharif suspected that the street protests to unseat him were being manipulated from behind the scenes by the army.
He also feared that, if the agitations turned violent, the army would exploit the situation to seize power for itself.
However, the two close aides who went to see army chief Raheel Sharif in the garrison town of Rawalpindi last Wednesday were told that the military had no intention of intervening.
"The military does not intend to carry out a coup but ... if the government wants to get through its many problems and the four remaining years of its term, it has to share space with the army," said the insider, summing up the message they were given.
"Sharing space" is a familiar euphemism for civilian governments focusing narrowly on domestic political affairs and leaving security and strategic policy to the army.
The fact that the military is back in the driving seat will make it harder for Sharif to deliver the rapprochement with India that he promised when he won the election last year.
Indian media speculated this week that Sharif had already been forced by the generals to scuttle peace talks.
New Delhi on Monday called off a meeting between foreign ministry officials of the two countries, which had been set to take place on Aug. 25, because Pakistan announced its intention to consult Kashmiri separatists ahead of the meeting.
The Himalayan region of Kashmir has been a bone of contention between India and Pakistan since both gained independence in 1947. The two nations have fought three wars, two of them over Kashmir, and came close to a fourth in 2001.
The Pakistani army's predominance could also mean it could torpedo the government's relationship with Afghanistan, where a regional jostle for influence is expected to intensify after the withdrawal of most foreign forces at the end of this year.
PAYING THE PRICE
Few believed that the army would back Khan's bid for power even if it used him to put Sharif on the defensive.
"Even the army knows that Imran Khan may be a great pressure cooker in the kitchen, but you can't trust him to be the chef," said a former intelligence chief who declined to be named.
Sharif may now pay the price for miscalculating that the military may have been willing to let the one-time cricket hero topple him.
"Thinking that Imran could be a game-changer, Nawaz has conceded the maximum to the army," a Sharif aide said.
"From a czar-like prime minister, they (the army) have reduced him to a deputy commissioner-type character who will deal with the day-to-day running of the country while they take care of the important stuff like Afghanistan and India. This is not a small loss."
But Sharif's aides say a stint in jail under Musharraf, followed by exile from Pakistan and five years as leader of the opposition party, have made him realise that he needs to share power to survive.
"This is not the old Nawaz, the wild confrontationalist," said an adviser to the prime minister in Lahore, the capital of his Punjab province power base. "This is the new Nawaz who has learnt the hard way that politics is about living to fight another day."