Pakistan's recent elections were supposed to bring in a period of stability, badly needed to deal with crippling inflation and bitter political divides in the country, writes author and journalist Mohammed Hanif.
Instead, they delivered a minority government - a shaky, reluctant coalition that looks unsure of its own mandate.
Two weeks after the elections, the Pakistan Muslim League (N) led by former prime minister Nawaz Sharif and Pakistan People's Party (PPP) led by Bilawal Bhutto announced that they would form a government but that the PPP wouldn't be part of it.
The midnight announcement by the leaders of both parties was made in sombre tones and had the air of a shotgun wedding.
Suddenly, Pakistan was that rare democracy where nobody really wanted to be the prime minister.
The "establishment" - a euphemism used by local media for Pakistan's powerful military - has always believed that general elections are too sensitive an exercise to be left to civilian politicians.
This time around they opened their old election playbook and used every trick deployed successfully in the past.
The main contender Imran Khan was put in jail. He faces more than 150 criminal and civil charges, all of which he denies.
A week before the elections he was sentenced in three cases - in one he was accused of contracting a marriage in a hurry. His party, denied its election symbol and a united platform, were forced to contest as independents.
Ex-PM Nawaz Sharif was widely seen as having the army's backing
Many were evading police raids instead of campaigning in their constituencies. His main opponents were cleared of many cases against them and given a free hand to campaign.
On election day social media and mobile phone services were shut down, apparently for security concerns but in reality, to ensure that Khan supporters didn't have easy access to the polling booths and would find it hard to identify their candidates on the ballot paper.
Khan's supporters showed remarkable ingenuity, formed WhatsApp groups, improvised apps and websites overnight and reached polling booths and managed to find their candidates.
His party used AI-generated speeches to convey the message of their jailed leader. Imran Khan's prison ID number was turned into an election slogan.
They campaigned guerrilla-style and sprang a surprise on election day.
Despite all the claims of rigging against it, his Pakistan Tehreek-e-Insaf (PTI) still emerged as the single largest party in the election. The Khan wave on election day was too strong to be reined in by routine rigging.
The establishment used 20th-Century tactics to tame a digital savvy generation - and lost.
To the military's tried and tested machinations, the voters' response was polite and defiant: thank you, but no thank you, we are not as ignorant and illiterate as you think we are. We may not be able to take you on in the streets, you have your guns, but here's our stamp on the ballot. Do what you will with it.
Imran Khan didn't get a simple majority in parliament, refused to align with any other parties to form the government and decided to sit in opposition.
He has built his campaign and overall charisma by portraying his opponents as corrupt. He is loath to share power with the politicians he has been attacking most of his political career.
Most Pakistani politicians have had to spend time in prison at some point. But no one seems to have had more fun than Imran Khan.
Denied every public platform to reach his supporters, he has pulled off an election victory from his prison cell with communiques sent through his lawyers and close family.
Last May, when Imran Khan was arrested for the first time after his government's dismissal, his supporters rioted, attacking army cantonments and other symbols of the army's power and prestige. A senior general's house was set on fire, and some rioters even managed to enter army headquarters.
Protests broke out after Khan was arrested over corruption allegations
The crackdown that followed was swift and brutal.
Most of the PTI top leadership was abducted and pressured to part ways with Imran Khan - some condemned his politics, others quit politics for life.
The establishment wanted to send out a clear signal that Imran Khan and his party were finished. With Khan in jail, as the election drew closer, the party was taken over by second-tier leadership and local faithfuls who were crucial in organising the battered party's campaign to victory.
They were certain that their leader would not be allowed to return to power, but they showed through their vote that they wouldn't abandon him just because the army wanted them to.
Imran Khan, when out of power, is the king of chaos, unleashing his wrath not only on his political opponents but the army establishment as well.
Before he was arrested and put away, Imran Khan claimed in his speeches that he was ousted at the behest of the US for pursuing an independent foreign policy.
His opponents say that all his policies while in power were only about his own ego and whimsy. When in power, they say, he spent more time hounding his opponents than he did running the country. While in government Khan seemed distracted and failed to make timely decisions to rein in runaway inflation.
Even in government he sounded like an opposition politician, raging against his political enemies and the media.
He is a seasoned agitator.
When his party lost the 2013 elections, he campaigned relentlessly to get the results overturned and laid siege to the capital Islamabad. He was able to do it with the establishment's backing. Now that he is the establishment's enemy number one he is buoyant after his party's showing at the polls.
His party has decided to sit in opposition, but Imran Khan likes to play his politics not in parliament but out on the streets, with public rallies and social media. The current government is already being dubbed as a "coalition of losers" - it literally is a coalition of parties that were soundly beaten by Khan in the elections.
The election was marred by the suspension of mobile phone services
For two weeks after the result there didn't seem to be any enthusiasm to form a government amongst Khan's opponents.
For the first time, leading politicians instead of laying claim to power were reluctant to accept responsibility.
There's reluctance to govern because Pakistan faces a crushing debt crisis and rising fuel and food prices have made life unbearable for the working classes. With the army's increased role in every sphere of governance, ruling politicians are reduced to going around the world asking international donors for bailouts.
Many have speculated if Imran Khan's time in jail will make him a more mature politician.
It seems unlikely.
He has thrived as a maverick - he will not want to turn into a meek version of himself to become acceptable to the establishment.
His rage against the old political guard has made him the most popular leader in Pakistan.
He wouldn't want to abandon that to run a country which even his losing opponents seem reluctant to govern.
This is the perfect environment for Imran Khan to continue his crusade, even from his jail cell as the country's most famous prisoner - number 804.