More than 370,000 troops deployed as tens of millions turn out to vote
Pakistan votes in general election as ISIS attack kills dozens
Pakistan's polls closed on Wednesday night after a closely fought general election marred by a deadly suicide bombing that killed 31.
Tens of millions of voters turned out for a poll that could propel the cricketer-turned politician Imran Khan to power in the nuclear-armed nation of 210 million.
Results are expected to trickle in overnight from the country's 85,000 polling stations, with the outcome of the country's second ever democratic transition of power starting to emerge early on Thursday morning.
Pakistan's largest ever election day security operation and the deployment of more than 370,000 troops failed to stop an ISIS bomber from causing carnage outside a Quetta polling station.
The local branch of the extremist group said it had tried to target a local police chief, but he had escaped.
Officials said the bomber had tried to enter a polling station and had then detonated when he was stopped at the door by police.
"Suddenly there was a huge blast. I was flung on the ground and I thought that I was about to die," madrassa teacher Hafiz Kareem told AFP.
Read more on Pakistan elections:
Sporadic clashes between the two leading rival parties also raised fears that any result could be met by violence. Pre-election polls had shown little difference in support between Mr Khan's Pakistan Tehreek-i-Insaf (Pakistan Justice Movement) and Nawaz Sharif's Pakistan Muslim League (PML-N).
In the worst skirmish rival activists in the Punjab city of Khanewal opened fire at each other, hurled clubs and threw stones. Four people were hospitalised with bullet wounds and one of them died.
The PML-N, Pakistan's largest party, won a landslide in 2013 and seemed destined to repeat the feat this month. But the legal hurdles faced by the Sharif family this past year has seen the party debilitated and struggling for survival against its main rival.
Mr Sharif has said the barrage of legal action is not coincidental. He was jailed nearly a fortnight ago after a corruption trial, his candidates say they have been pressured to switch to Mr Khan's centre-right party and the media has been harassed. Disliked by the military for his attempts to build bridges with India and for confronting generals over their use of militant proxies, he claims it has retaliated by trying to weaken his party.
Such an onslaught may have destroyed another party, but the PML-N are not yet written off. Mr Sharif's return to Pakistan to face a jail cell has allowed him to portray himself as a political martyr and the party remains a potent political force under his younger brother Shahbaz, particularly in Punjab.
Meanwhile, 22 years after founding his party, Mr Khan has his best ever shot at taking power. His platform, comprised of attacks on the country's political elite and corruption, has been strengthened by the jailing of Mr Sharif.
Yet some fear Mr Khan's mercurial nature and lack of management skills are unsuited to being prime minister.
He is renowned for making policy u-turns and has raised eyebrows by catering to religious hardliners, spurring fears his leadership could embolden extremists.
Voting followed a bitterly fought campaign. Mr Khan's platform of railing against the corruption and incompetence of Pakistan's political elite has excited a new generation of young voters.
But the centre-right PML-N say he is the candidate of the country's powerful military and benefiting from a concerted attempt by the security establishment to undermine Mr Sharif for daring to stand up to the country's generals.
Mr Khan has shed the playboy image of his cricketing heyday and has cultivated a more conservative and devout persona. He has promised to create 10 million new jobs and build an Islamic welfare state complete with world class hospitals and schools.
The PML-N, now led by Mr Sharif's younger brother Shahbaz, has been touting its success in reducing militant violence and improving the country's electricity supply.
“Imran Khan is a great person, and we want a new person to come in and lead us,” said 21-year-old engineering student Mohammed Hamza after voting in the garrison city of Rawalpindi.
“We need change because we have seen all the other leaders are the same. The main issue is corruption and Imran Khan will deal with this very well.”
He dismissed suggestions the army was engaged in pre-poll rigging to handicap the PML-N and favour Mr Khan.
He said: “The army is the most patriotic part of our country, the backbone of our country. If anything bad happens, then the steps in. These are just lame excuses to cover up their own bad stuff.”
But his brother, Mohammed Bilal, disagreed. The 27-year-old businessman said: “The army is not being open about it, but everyone knows the army is supporting Imran Khan because Nawaz Sharif argued with them so much. Corruption is a problem, but I think the PML-N have changed.”
Malik Sohail Akhtar, a Khan supporter in Rawalpindi said he had chosen to support the PTI because the 1992 cricket World Cup hero was not corrupt.
“He wants to make a better Pakistan. He wants other countries to respect Pakistan,” he told The National.
As the day wore on parties began to catalogue alleged irregularities and all three main parties requested extensions to polling, complaining voting was too slow in some stations. But the election commission rejected calls for an extension and voting closed at 5pm.
While the PTI has edged marginally ahead in the polling in recent weeks the forecasts suggest he will not win a majority. A hung parliament will trigger protracted horse-trading and coalition building just as the country needs a legitimate new leader to deal with a series of alarming challenges.
The country is heading towards a debt crisis and is expected to need a bailout from the International Monetary Fund as soon as September or October. Foreign currency reserves have dwindled sharply and the rupee has devalued three times since December.
Relations with its nuclear armed rival India are at an all-time low and in the longer term the country is desperately short of water for its rapidly growing population.