ISLAMABAD Pakistan's Nawaz Sharif declared victory in a jubilant speech to supporters as results from Saturday's election showed a clear lead for his party, making it almost certain that he will become prime minister of the country for a third time.
The election, in which 86 million people were eligible to vote, will bring the first transition between civilian governments in a country that has been ruled by the military for more than half of its turbulent history.
Despite pre-election violence and attacks on Saturday that killed at least 17 people, millions turned out to cast a ballot.
"Results are still coming in, but this much is confirmed: we're the single largest party so far," he declared to hoots of joy from the crowd. "Please pray that by morning we're in a position that we don't need the crutch of coalition partners."
With the count continuing into the night, Sharif's Pakistan Muslim League - Nawaz (PML-N) was leading in 119 of the 272 National Assembly seats that were contested.
Sharif's lead means he is almost certain to become prime minister again, a triumphant return for a political leader who was ousted in a military coup in 1999, jailed and later exiled.
It remains to be seen, however, if his PML-N will have enough lawmakers to rule on its own or be forced to seek coalition allies, which could make it difficult to push reforms desperately needed to revive a near-failed economy.
The next government will have to contend with Taliban militancy, endemic corruption, chronic power cuts and crumbling infrastructure in the nuclear-armed country of 180 million people. One of the first likely tasks will be to negotiate with the International Monetary Fund for a multi-billion-dollar bailout.
It is now clear that a dark-horse challenge by the party of former cricket star Imran Khan did not have the momentum needed to trip up Sharif, a moneyed political veteran who has long relied on a patronage system to win votes, especially in the key province of Punjab.
Still, Khan's Tehrik-i-Insaf (PTI) looked set to squeak into second place thanks to support from urban youths, who rallied behind his calls for an end to corruption and a halt to U.S. drone strikes against suspected militants on Pakistani soil.
That marks an end to decades of two-party dominance by the PML-N and Pakistan People's Party (PPP).
The PPP led the government for the past five years with 124 lawmakers in parliament. Eight hours after polling stations closed on Saturday it was ahead in the count for just 34 seats.
"Nawaz's victory says two things about Pakistan: one, the people of Pakistan prefer the comfort of status quo over the uncertainty of revolutions; and two, all roads to the centre go through Punjab, and in Punjab, people are right-leaning and conservative," said senior journalist Nusrat Javeed.
"Still, for a party PTI that only really arrived on the political scene in a serious way two years ago, PTI's performance was remarkable, to say the least."
BLOODY ELECTION DAY
Pakistan's Taliban, which is close to al Qaeda, has killed more than 125 people in election-related violence since April. The group, which is fighting to topple the U.S.-backed government, regards the election as un-Islamic.
More bloodshed marred election day. A bomb attack on the office of the Awami National Party in Karachi killed 11 people and wounded about 40.
In Baluchistan, four died in a gunbattle and, in another incident, gunmen on a motorcycle opened fire near a polling station, killing two people, police said. A separate attack on a convoy of voters killed at least four people in the province.
But despite the violence and the searing heat, many went to the polls excited about the prospect of change.
Despite Pakistan's history of coups, the army stayed out of politics during the five years of the last government and threw its support behind Saturday's election.
It still sets foreign and security policy and will steer the thorny relationship with Washington as NATO troops withdraw from neighbouring Afghanistan in 2014.
However, some fear the military could step back in if there is a repeat of the incompetence and corruption that frustrated many Pakistanis during the last government.
On top of the 272 contested seats, a further 70 - most reserved for women and members of non-Muslim minorities - are allocated to parties on the basis of their performance in the constituencies. To have a majority of the total of 342, a party would need 172 seats.
(Writing by John Chalmers and Michael Georgy; Additional reporting by Gul Yousafzai in QUETTA, Mubasher Bukhari in LAHORE and Jibran Ahmed in PESHAWAR; Editing by Alison Williams and Jon Hemming)