Official results from Pakistan’s legislative elections show opposition leader Imran Khan’s Tehrik-e Insaf (PTI) party winning the vote and taking 109 of 269 seats being contested in the National Assembly.
But with the PTI falling short of the 137 seats needed to control a parliamentary majority, the party will have to seek out allies in the legislature to form a coalition government.
Pakistani election officials early on July 27 said the results show Khan's nearest rival, the current ruling Pakistan Muslim League-Nawaz (PML-N) of jailed former Prime Minister Nawaz Sharif, winning 63 seats.
Third place went to the left-of-center Pakistan Peoples Party (PPP) with 39 seats. Results from 20 seats were still being counted, AP said.
Sixty seats in the National Assembly are reserved specifically for women, and 10 for non-Muslim minorities.
Earlier, Reuters had reported that provisional results released by the Election Commission of Pakistan showed Khan's party had won 110 seats out of the 251 races where counting had ended, with Sharif's party winning 63 seats and the PPP winning 42 seats. The National Assembly has 272 seats in total.
Earlier, Khan declared victory in the elections, which were marred by delayed vote counting and violence as well as allegations of rigging by Khan's rivals.
In a televised speech on July 26, Khan said: "Thanks to God, we won and were successful," adding that "if God wills, we will set an example."
Sharif's PML-N and several other parties rejected early results from the vote count, alleging major vote-rigging and manipulation of the elections.
But Pakistani election officials denied there was widespread fraud.
In his July 26 speech, Khan called for "mutually beneficial" ties with the United States despite strained diplomatic relations.
"Unfortunately, our relations have so far remained one-way," said the 65-year-old. "I mean the U.S. assists Pakistan so that it can help fight the American war [in Afghanistan]. This has damaged Pakistan a lot. We want a relationship that is...balanced."
He also expressed support for peace in neighboring Afghanistan.
Kabul and Washington accuse Islamabad of providing safe havens for militant groups like the Afghan Taliban and Haqqani network that are fighting Afghan and U.S. troops in Afghanistan.
"If Afghanistan is at peace, Pakistan will also have peace," Khan said. "Our government will try its best to bring peace in Afghanistan."
He also offered an olive branch to arch-rival India, saying the two nuclear-armed nations should resolve a longstanding dispute over the Himalayan region of Kashmir.
If confirmed as prime minister after coalition negotiations, Khan's victory would mark his stunning rise from struggling politician to the highest civilian office in the country.
Born to a privileged family and educated at Britain's Oxford University, Khan was known for his playboy lifestyle and married wealthy British heiress Jemima Goldsmith in 1996. He has since remarried twice.
Khan has criticized Pakistani liberals and embraced conservative Islam as a politician, promising a "new Pakistan" with an Islamic welfare state and an Islamic justice system. A populist who ran on an anticorruption campaign, he has allied himself with extremist religious groups with ties to militancy.
He has characterized his campaign as a battle against a political elite -- dominated by long-established parties like the PML-N and PPP -- that he accuses of hindering economic development in the impoverished country of 201 million people.
Khan is also widely believed to be backed by the army, which fell out with Nawaz Sharif, who looked to curb the military’s traditional dominance in politics.
Khan has been an outspoken critic of the U.S.-led war in neighboring Afghanistan and of U.S. drone strikes against militants in Pakistan.
But analysts doubt Khan can radically change Pakistan's foreign policy, which is shaped by the army.
Pakistan's military has ruled for approximately half the period since the country’s independence in 1947, staging coups three times.