Sharif, imprisoned since mid-July, is starting one of the last chapters of his long career from a cell, where the 68-year-old is serving a 10-year sentence for corruption
Three times he has ruled Pakistan, and three times he has been deposed. Now Nawaz Sharif, the "Lion of Punjab", is being forced to watch the triumph of his great rival Imran Khan from behind bars.
Sharif, imprisoned since mid-July, is starting one of the last chapters of his long career from a cell, where the 68-year-old is serving a 10-year sentence for corruption.
His daughter and political heir Maryam is similarly imprisoned, while his wife Kulsoom is fighting cancer thousands of miles away in London. Sharif himself is also in frail health.
And the great gamble he took in returning to Pakistan days ahead of the July 25 election has failed to galvanise support. Instead, Khan is set to take the oath as prime minister and usher in a "New Pakistan" on August 18.
"Now is the time to see how history remembers him," says Muhammad Zubair, a senior member of Sharif's eponymous Pakistan Muslim League-Nawaz (PML-N).
Such a scenario seemed unthinkable a year ago when Sharif, then a popular prime minister hailed for his infrastructure projects, seemed to be moving towards easy re-election.
The Supreme Court shattered his momentum on July 28, 2017, controversially deposing him following a corruption investigation. He was banned from politics, and finally jailed just two weeks before the vote.
The "Lion of Punjab", named for the wealthy province which is his family stronghold, has insisted that the powerful Pakistani army -- assisted by the judiciary -- orchestrated his fall.
Khan, who captained Pakistan to World Cup cricket victory in 1992, has dismissed the claims, as have the generals.
But Sharif is not alone: observers have described the campaign as the "dirtiest" in Pakistan's history because of widespread allegations of military interference. The opposition is protesting against alleged electoral fraud.
Supporters say Pakistanis will remember that Sharif and daughter Maryam were in London with his ailing wife when their jail sentences were handed down.
They chose to return to Pakistan, where they were arrested as soon as they landed.
But the hoped-for surge of support for his party -- led into the campaign by his less charismatic brother, Shahbaz -- has not materialised. Once ubiquitous in the media, Sharif has issued no public statement in weeks.
"They wanted to sell this politically. But the gamble didn't pay off," analyst Fahd Husain said.
Sharif is "being punished only for one reason, and that reason is that he is not bowing his head" to the military, Mushahidullah Khan, a former PML-N minister, told AFP.
Imran Khan, who first instigated the corruption charges against Sharif, has told AFP the PML-N's claims are "conspiracy theories" and a "smokescreen".
The court decision ousting Sharif may have been controversial, but repeated accusations over decades mean he is widely perceived as corrupt. Critics dismiss him as a leader who stole billions from Pakistan, giving Khan's vow to end graft an extra edge.
But Sharif's supporters staunchly frame his ouster as part of the long battle between the civilian and military leadership for power in Pakistan, whose history is punctuated by coups and assassinations.
"(Sharif) is fighting for civilian supremacy. If he is going to jail, it is worth giving that sacrifice," says the PML-N's Zubair.
Sharif has been down and out before. Expelled from power in 1993 on suspicion of corruption, he won the 1997 election, only to be ousted and exiled after a military coup in 1999.
He returned in 2007, and took power once more in 2013.
Zubair said he will not fight for a fourth term. Now, it is his political legacy at stake.
Saving that might not be up to him. "If (Imran Khan's party) does well, Nawaz Sharif's narrative will be diluted," said the analyst Husain.
The PML-N has criticised the conditions of Sharif's detention. Sharif, who suffers from high blood pressure, was briefly hospitalised in late July.
"He looks far better than the first time," Zubair, who visits Sharif regularly, told AFP.
The ex-prime minister is "not in the worst possible cell", and even has a television with three channels -- state-run PTV, a weather channel and a sports channel.
But he is in solitary confinement. "He is not even allowed to meet Maryam, other than on Sundays," Zubair said.
His fate has divided once-fervent supporters.
"Many PML-N leaders told him not to speak against the army and judiciary, but he didn't listen," said Naja Nisar, an estate agent in Rawalpindi.
Kashan Arshid, a former party youth leader in Rawalpindi, is unwilling to write Sharif off.
"It's the third time he's suffered. Each time ... people say he is finished," Arshid said.
"But every time he comes back, stronger. The lion will roar again."