Here's a little fairytale from Pakistan. Fourteen years ago a wise man ruled the country. He enjoyed the support of his people. But some of his treacherous generals thought he wasn't that smart. One night, he was held at gunpoint, handcuffed, put in a dark dungeon and sentenced to life imprisonment. But then a little miracle happened; he, along with his family and servants, was put on a royal plane and exiled to Saudi Arabia, that fancy retirement home for the world's unwanted Muslim leaders. A few days ago that same man stood on a balcony in Lahore, thanked Allah and said: Nawaz Sharif forgives them all.

But wait, if it was a real fairytale, Imran Khan would have won the election instead, right? Can't Pakistani voters tell between a world-famous, world cup-winning, charismatic leader and a mere politician, who refers to himself in the third person?

Why didn't Imran Khan win?

Well he has, sort of. But not in the way he would have liked. Visiting foreign journalists have profiled Khan more than they have profiled any living thing in this part of the world. If all the world's magazine editors were allowed to vote for  Khan, he would be the PM of half the English-speaking world. If he had contested in West London, he would have won hands-down. But since this is Pakistan, he has won in Peshawar and two other cities. His party is set to form a government in KPK, which Khan’s profile writers never fail to remind us is the province that borders Afghanistan and the tribal areas that the world is so scared of. Or as some others never fail to remind the world: the land of the fierce pathans.

It is true that Khan ran a fierce, bloody-minded campaign, drawing huge crowds. When his campaign culminated in a televised tumble from a stage, during a public rally, the whole nation held its breath. He galvanised not only Pakistan's parasitical upper classes, but also found support among the country's young men and women of all ages; basically, the kind of people who use the words politics and politician as common insults. He inspired drawing-room revolutionaries to go out and stand in the blistering heat for hours on end to vote for him. For a few months, he made politics hip in Pakistan. Partly, he was relying on votes from Pakistan's posh locales. He, probably, forgot that there was a slight problem there: not enough posh locales in Pakistan. There were kids, who flew in from Chicago and Birmingham to vote for him. Again, there are not enough Pakistani kids living and studying in Chicago and Birmingham. He appealed to the educated middle classes, but Pakistan's main problem is that there aren't enough educated urban middle-class citizens in the country. And the masses, it appears, were not really clamouring for a revolution but for electricity.

From the gossip columns of British tabloids to massive political rallies across Pakistan, Khan has been on a meaningful journey. In his campaign speeches, his blatantly Blairite message of ‘New Pakistan’ did appeal to people, but he really tested his supporters' attention span when he started to lecture them about how the Scandinavian welfare state model is borrowed from the early days of the Islamic empire in Arabia. Amateur historians have never fared well in Pakistani politics. Or anywhere else. Khan promised to turn Pakistan into Sweden, Norway or any one of those countries where everyone is blond and pays tax. His opponents promised Dubai - where everyone is either a bonded labourer or a property speculator and no one pays taxes - and won.

It is a bit of a fairytale that Khan, whose message was directed at educated urban voters, has found supporters in the KPK (formerly) that profile writers must remind us is largely tribal and the front line of the war on terror. Khan has led a popular campaign against drone attacks. He has promised that he will shoot down drones, look Americans in the eye, sit down with the Taliban over a cup of qahwa and sort this mess out. So we finally have someone who feels at home in Mayfair as well as Peshawar. He finally has the chance to rule Peshawar. Slight problem: as he speaks no Pashto, the language of the Pathans. But his first fight will be against American drones hovering in the sky. And drones speak no Pashto either. If Khan can win this match, he can challenge Sharif in the next elections.

Is this Nawaz Sharif man for real?

Hasn't he been tried before? Twice? It seems voters in the largest province of Pakistani Punjab just can't have enough of this guy. At every campaign stop, Sharif reminded his supporters of two of his biggest achievements: I built the motorway, I built the bomb. He did build Pakistan's first motorway. And despite several phone calls from the then US President Bill Clinton and other world leaders and offers of millions of dollars in aid, Sharif did go ahead and ordered six nuclear explosions in response to India's five. And then he thought that now that both countries have the bomb he could go ahead and be friends with India. While he was making history hosting the Indian PM in the historic city of Lahore, his generals were busy elsewhere repeating history on the mountains of Kargil. In a misadventure typical of Pakistani generals, they occupied the abandoned posts and then pretended that these were mujahideen fighting India and not regular Pakistan army soldiers.

When India reacted with overwhelming force and a diplomatic offensive, Sharif pleaded ignorance and rushed off to Washington to bail out the army and his own government. President Clinton praised his diplomatic skills and the crisis was resolved briefly. When, months later he tried to fire his handpicked Army Chief General Pervez Musharraf, a bunch of army officers put their guns to Sharif's head. Handcuffed, jailed, sentenced to life imprisonment, in the end Sharif was saved by his powerful friends in Saudi Arabia. A royal jet flew him, his family and his servants to a palace in Saudi Arabia. An exile in Saudi Arabia for Muslim rulers is generally considered a permanent retirement home where you get closer to Allah and atone for past sins. Sharif must be the only politician in exile in Saudi Arabia, who not only managed to survive this holy exile, but in the process managed to hold on to his political base in Pakistan.

Many of his political opponents say that if Sharif was not from the dominant province Punjab, where most of the army elite comes from, if he didn't represent the trading and business classes of Punjab, he would still be begging forgiveness for his sins in Saudi Arabia. But he returned just before the last elections and has been behaving like a statesman. It has yet to be proven whether eight years of exile in Saudi Arabia can make anyone wiser, but it has never made anybody poorer. Sharif was rich before he got into politics, then he became fabulously rich. Even in exile the Saudis gave him a palace and, on his return, a fleet of bulletproof limousines. His campaign proved that poor people don't really vote for somebody who understands poverty, or wants to do anything about it. People have voted him in because he talks money, talks about spending money, talks about opening a bank on every village street and who doesn't like that? He has promised motorway connections and airports to towns so small that they still don't have a proper bus station. Poor people, who could not afford a bicycle at the time of the elections, like to be promised an airport. You never know when you might need it.

In his five years' rule in Punjab, Sharif's party has had one policy about the Pakistani Taliban, who have been wreaking havoc in parts of Pakistan: please go and do your business elsewhere. And they have generally obliged. But now that he is set to rule all of Pakistan, what is he going to tell them?

–To be continued

The writer is BBC Urdu's special correspondent and has authored two books, “A Case of Exploding Mangoes” and “Our Lady of Alice Bhatti”. This article has been reprinted from The Guardian.