Pakistan's Nawaz Sharif has declared victory in a jubilant speech to supporters as results from today'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 86m 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 today 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, Mr Sharif's Pakistan Muslim League - Nawaz (PML-N) was leading in 119 of the 272 National Assembly seats that were contested.

Mr 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 MPs 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 180m people.

One of the first likely tasks will be to negotiate with the International Monetary Fund for a multi-billion-dollar bailout.