Nawaz Sharif, leader of the Pakistan Muslim League - Nawaz (PML-N) political party, waves as he arrives to cast his vote for the general election at a polling station in Lahore. (Reuters)
Nawaz Sharif made a stunning comeback to power on Sunday, 14 years after being deposed in a military coup and spending years in jail and exile.
With counting still on late at night, the 63-year-old's Pakistan Muslim League-N (PML-N) was well ahead with more than 128 of the 272 directly elected seats of the national assembly, according to projections by TV channels.
Sources said he was already in talks to form the next government.
Imran Khan's Pakistan Tehrik-e-Insaf party (PTI) achieved its own breakthrough on an anti-corruption platform that resonated with younger voters.
It was neck and neck with the outgoing Pakistan People's Party (PPP) on 30 to 25 seats, a remarkable achievement given it only won one seat previously, in 2002. Poll tally
Congratulating Sharif on an "emphatic victory", Prime Minister Manmohan Singh wrote to him: "The people of India welcome your publicly articulated commitment to a relationship between India and Pakistan that is defined by peace, friendship and cooperation. I look forward to working with you and your government." Read full text of PM's letter
This is the first time Pakistan is marking one elected civilian administration handing over power to another after a full term.
In his party manifesto and before the media, Sharif has said the Lahore accord remains the touchstone of his India policy.
"We will start from where we were interrupted in 1999," he told TV anchor Karan Thapar.
Under the treaty, the neighbours reached a mutual understanding on the development and use of nuclear weapons. Sharif takes great pride in Lahore, seeing it as a personal achievement he must complete.
"Nawaz Sharif is very serious about better relations with India. (President Asif Ali) Zardari was thwarted by the establishment. Being a Punjabi and a mandate from Punjab, Sharif can do much more," says retired Pakistani general Talat Masood.
If Lahore is one of the threads of the past he plans to pick up, the other is his vendetta against Pervez Musharraf, the general who wrecked Lahore and overthrew him.
Sharif's promise to reveal all about Kargil is more about getting at Musharraf than about winning Indian trust.
However, normalising relations with India fits in with two elements of the agenda Sharif will pursue in the coming years.
First is granting most-favoured nation status to India and otherwise normalising economic ties.
Sharif shares the view of most civilian politicians that Pakistan's economy has done well out of trade - and India is the one obvious market left to be tapped.
"Sharif understands that if done correctly, Indian imports will be cheaper and help tackle inflation," says Pakistani economist Asad Saeed.
Second is Sharif's campaign statements that civilian control of the military is a must in today's Pakistan. To make the case for this, he has to reduce the threat perception regarding India.
As PM, Sharif may wish to do a lot with India but delivery will be an exercise in patience.
Taking on the army, for example, will be easier said than done. It would mean confronting Punjabi militants like the Lashkar-e-Taiba, groups which, notes Pakistani analyst Ayesha Siddiqa, he once nurtured and were backed by his Punjab party.
"The military will use Imran Khan and the Taliban against him if he goes too far," believes Rana Banerjee, Pakistan expert at the Delhi-based Centre for Policy Research.
The expectation is that Sharif will move stealthily.
He will support existing moves to bring the ISI's activities under civilian scrutiny. On the diplomatic front, he will resurrect the back-channel diplomatic talks that fell into disuse after Musharraf's fall.
New Delhi will be agreeable to this cautious pace.
The Manmohan Singh government is on its last legs and the election cycle is in full swing. Sharif has the mandate to consider a Kashmir settlement; Singh does not.
For India, say officials, the main accomplishment of the election will be a stable and powerful civilian government in Islamabad headed by a known quantity.
With agency inputs