Millions of Pakistanis came out to vote in landmark general elections on Saturday, braving Taliban attacks that left 22 dead.
Late on Saturday night, former prime minister Nawaz Sharif declared
victory for his centre-right Pakistan Muslim League-N (PML-N) party and invited other parties to work with him.
Poll predictions had suggested a neck-and-neck race between Nawaz Sharif and Imran Khan.
A record turnout - possibly 60%, with first-time and women voters putting up a strong show - could give Khan's Pakistan Tehreek-e-Insaf party a better result than previous outings.
However, Sharif has remained the favourite to be PM.
Both won their individual contests. Other major parties have largely been restricted to their strongholds.
A string of militant attacks and gunfights cast a shadow over the polls, which will bring the first transition between civilian governments in the country.
A bomb attack on the office of the Awami National Party in Karachi killed 11 and wounded 40. The Pakistan Taliban claimed responsibility. At least two were wounded in three blasts later.
A bomb exploded outside a polling station in Peshawar, killing one. In Balochistan, gunmen killed two outside a polling station and a shootout between supporters of rival candidates ended with four dead.
Malala Yousufzai, the teenager who took on the Taliban, had a message for her country: exercise your franchise as "one vote can change" Pakistan's future.
Amid allegations of rigging and irregularities in Karachi and parts of Punjab, the high voter turnout flew in the face of Taliban advice to people to stay home.
The poll commission conceded arrangements in some constituencies were unsatisfactory and some voting irregularities had occurred.
But it insisted voting was largely free and fair - a view endorsed by local poll observers.
With agency inputs