That scrambled the plans of Sharif — and the security establishment backing him — forcing him to announce plans Friday to try to form a coalition government.
A day earlier, Sharif had gruffly rejected the idea of a coalition, confidently telling reporters after casting his vote that he wanted a single party running Pakistan for a full five-year term.
Khan, a former cricket star turned Islamist politician with a significant grassroots following, was disqualified from running in Thursday's election because of criminal convictions. He contends his sentences and a slew of legal cases pending against him were politically motivated.
Khan’s party’s candidates were forced to run as independents after they were barred from using the party symbol — a cricket bat — to help illiterate voters find them on ballots.
Despite those setbacks — and with most of the 266 National Assembly constituencies announced by the election oversight body — candidates backed by Khan’s Pakistan Tehreek-e-Insaf party, or PTI, had won 99 seats. Sharif's Pakistan Muslim League party had 71 seats. The election was postponed in one constituency because of the killing of one of the candidates.
However, with a third major party in the mix, nobody could declare outright victory.
Sharif acknowledged that, telling supporters “we don’t have enough of a majority to form a government without the support of others and we invite allies to join the coalition so we can make joint efforts to pull Pakistan out of its problems.”
“We will have to sit together to settle all matters,” he said.
However, Pakistan’s deeply divided political climate is unlikely to produce a strong coalition pushing for the betterment of a country grappling with high inflation, year-round energy outages and militant attacks.
The lack of a majority did not stop Sharif's relatives and loyalists from appearing on a balcony at his party headquarters, waving to the crowds below. People threw rose petals on Sharif's car as he arrived to address party workers.
Meanwhile, PTI chairman Gohar Khan told Pakistani news channel Geo that his party's own count showed it securing a total of 150 seats, enough to form a government, though 169 seats are required for a majority in the 336-seat National Assembly, or lower house of parliament.
Observers had expected Sharif's Pakistan Muslim League to prevail and put him on track for a fourth term as prime minister due to the disadvantages faced by Khan's party. Along with Khan imprisoned and facing more criminal convictions, election officials and police blocked his party from holding rallies and opening campaign offices, and its online events were blocked.
The PTI said the moves were intended to prevent them from competing and gaining momentum with voters.
Sharif said he would approach the Pakistan People's Party of Bilawal Bhutto-Zardari, the son of assassinated former Prime Minister Benazir Bhutto, as a coalition partner. The PPP has 53 seats. Sharif’s rivals, including Bhutto-Zardari, criticized him on the campaign trail so the coalition he seeks is apparently aimed at keeping Khan in prison and the PTI out of politics.
U.S. State Department spokesperson Matthew Miller said the elections included undue restrictions on freedoms of expression, association and peaceful assembly.
“We condemn electoral violence, restrictions on the exercise of human rights and fundamental freedoms, including attacks on media workers, and restrictions on access to the Internet and telecommunication services, and are concerned about allegations of interference in the electoral process,” Miller said.
The European Union said it regretted the lack of a level playing field due to the inability of some political actors to contest the elections.
It called on authorities to ensure “a timely and full investigation” of all reported election irregularities.
Sporadic violence and an unprecedented nationwide cellphone service shutdown overshadowed Thursday's voting.
Violence persisted Friday, with two people killed and six injured in the northwest district of Shangla after clashes broke out between Khan supporters protesting against vote-rigging and security forces, police official Sadique Khan said. PTI supporters also protested against vote-rigging in Peshawar city, the capital of Khyber Pakhtunkhwa province.
Sharif and Khan's circumstances on election day represented a reversal of fortunes for the two men. Sharif returned to Pakistan in October after four years of self-imposed exile abroad to avoid serving prison sentences. Within weeks of his return, his convictions were overturned, leaving him free to seek a fourth term.
The ease of his comeback marked him as the preferred candidate of the security establishment, which casts itself as the ultimate arbiter of who comes to power in Pakistan and what decisions they make.
It's parliament that chooses the prime minister. But the success of Khan-backed candidates against the odds means Sharif will have to woo all politicians with assembly seats if he wants to lead the country again.
Ahmed reported from Islamabad.