Ousted Pakistani Prime Minister Nawaz Sharif gestures as he boards a Lahore-bound flight due for departure, at Abu Dhabi International Airport, UAE July 13. (Drazen Gorgic/Reuters)

This post has been updated, 1:15 p.m.

Right after sweeping the 2013 elections in Pakistan, Nawaz Sharif told me that as prime minister he would show the world that he, not Pakistan’s army chief, was the real boss. But now, on the eve of Pakistan’s next election, he has returned from London (where he went to visit his ailing wife) to face not only jail time but a military establishment that is determined to finish him.

In choosing to return (instead of opting for exile) and possibly spend 10 years in prison for corruption, he has in fact given his party, the Pakistan Muslim League (Nawaz) (PML-N), a fresh burst of energy — and maybe even an advantage — in the imminent elections. Flanked by his daughter and political heir, Maryam, Sharif has presented himself as the only Pakistani civilian with the courage to take on an army that has ruled Pakistan by either diktat or stealth for the past 70 years.

The three-time prime minister’s hold over his government began unraveling when his family was named in the Panama Papers leak in 2016. He and his daughter were eventually convicted and barred from contesting elections because Pakistan’s special anti-corruption court decided the family had been unable to disclose how they funded four luxury flats in London. The court acquitted Sharif of the charge that he acquired the flats by corrupt or illegal means but ruled that the purchase of the properties was beyond the range of Sharif’s known and disclosed income. Before this jail verdict, Sharif had been removed from the post of prime minister by Pakistan’s Supreme Court for not being “honest” or “truthful.” These vaguely worded descriptions (otherwise known as “ameen” and “sadiq,” respectively) are two of the most contentious articles in Pakistan law and were brought into force by its most despotic military dictator, Mohammed Zia ul-Haq.

No matter where you stand on the corruption allegations against Sharif, there is a wide consensus among ordinary Pakistanis that Sharif has been punished disproportionately. The corruption case may well be an attempt to undermine the autonomy of civilian politicians in Pakistan’s stunted democracy. In a country where not a single prime minister has ever completed a five-year term, Sharif’s case has been called a judicial coup.

And that is precisely why Imran Khan, who is Sharif’s main challenger and could even become the country’s next prime minister, should not be celebrating the fall of his rival.

Khan is a glamorous, Mick Jagger-lookalike cricketer turned politician, who opponents say has the blessings of the shadowy deep state that controls the country. He has described supporters of Sharif, who came out on the streets of Lahore to defy deployed police officers, as “donkeys” (a south Asian colloquialism for stupidity). He has ignored the embarrassing tabloid headlines (about sexual affairs and unacknowledged children) that have emerged from a strategically timed book written by his ex-wife Reham. Instead, Khan, who once told me in an interview that liberals are the “scum of Pakistan,” has carefully built his entire political campaign on being anti-corruption and anti-poverty and promoting anti-Americanism. The Oxford-educated former captain of the country’s cricket team — who has courted social conservatives and fundamentalist clerics — wants Pakistan to be an Islamic welfare state.

But what Khan is missing in his pursuit of the top job is obvious: Today it might be Sharif, but tomorrow it could be Khan. After all, if Khan is seen today as the flavor of the season for the Pakistani military, those who know Pakistan remember the years when Sharif too was a military protege. But it all turned on a dime. The very moment Sharif stood up to the intelligence agencies and the army and moved to sack Army Chief Pervez Musharraf (who later deposed him in a coup in 1999), he was a marked man. Can Khan’s fate really be any different?

Friends in Pakistani media tell me there is unprecedented state control over the mainstream media. Speeches by Sharif and his daughter were taken off the air. Orders were issued to not show a live broadcast of his return to Pakistan or his subsequent arrest. Interviews with the Sharif family were dropped or censored after being recorded. Party workers were rounded up and arrested, compelling even politicians opposed to Sharif to call for the right to peaceful protest.

But while Sharif and his daughter have been sent packing to prison, the deep state’s mainstreaming of Pakistan’s “good terrorists” (militant groups it treats as strategic assets against India and in Afghanistan) is well underway. How else does one explain that while Sharif has been sentenced for owning four apartments worth a few million pounds, Hafiz Mohammed Saeed, who is accused of being involved in the Mumbai terrorist attacks in 2008, is not only free but also actively campaigning in these elections for a newly created political party, the Allah-o-Akbar-Tehreek?

Sharif returned to Pakistan on a day when at least 133  Pakistanis were killed in a suicide attack by the Islamic State in the province of Balochistan. But no carnage seems big enough to end the incoherence of Pakistan’s patronage of terrorist groups and its military’s engineering of whom to legitimize and whom to discard.

Of course, as a hard-nosed politician, Sharif is no saint. But how does one make sense of a country in which Saeed, who co-founded Lashkar-e-Taiba, a globally acknowledged terrorist group, can cut ribbons with impunity while a former elected prime minister goes to jail for financial corruption? Sharif is hoping that his constituents will see it the same way. And even his fiercest critics have granted him fulsome credit for the bravery he showed in coming home.

In the past, Sharif and his arch-rival Benazir Bhutto joined hands to drive out Musharraf. Today, her son Bilawal, Khan and Sharif may well want to consider an attempt at a national civilian government that brings all political parties on one platform.

That is the only solution that could provide some insurance against a Pakistani security establishment that has perfected the art of the non-coup coup.