Despite former PM Imran Khan's detention and the many hurdles thrown at his Pakistan Tehreek-e-Insaf (PTI), independent candidates backed by the party stunned observers by winning 93 National Assembly seats, the most by any party. However it is far short of the 169-seat simple majority required to form a government.
The Pakistan Muslim League Nawaz (PML-N) of another former PM, Nawaz Sharif, came in second with 75 seats. He was seen to have the backing of the country's powerful military and had been expected to coast to victory, five years after he left Pakistan in disgrace.
The Pakistan People's Party (PPP), led by political blue blood Bilawal Bhutto Zardari, came in third with 54 seats.
The constitution dictates that political parties must form a government by 29 February, or three weeks after election day. The National Assembly has a total of 336 seats, of which 266 are decided by direct voting and 70 are reserved - 60 for women and 10 for non-Muslims - and these are allocated according to the strength of each party in the assembly.
"It's a fragmented mandate where none of the parties have a simple majority. And yet they will have to find a common ground or form a coalition to exist," political analyst Rafiullah Kakar told BBC Urdu from Islamabad.
While both the PTI and PML-N have declared victory, a coalition government appears inevitable. As wrangling continues, independent candidates who did not win have flooded courts with vote-rigging allegations. Supporters of PTI have also staged protests outside Election Commission offices across the country.
One likely scenario could see PML-N forming a coalition with the PPP, as well as some smaller parties, Prof Samina Yasmeen of the University of Western Australia told the BBC's Newsday. The two parties formed an alliance to oust Mr Khan from power in 2022 and ruled until last August.
"The sticking point would be who would be the next prime minister (and) what would be the division in terms of the president's position, but also within the different provinces," she added.
The PML-N is courting the social liberal Muttahida Qaumi Movement (MQM), which won 17 seats. It is also looking to entice independent candidates to its side.
While Mr Zardari met a PML-N delegation led by Mr Sharif's brother Shehbaz in Lahore on Sunday, the PPP appears to be be taking its time to consider its options. The party's central executive committee is set to meet in Islamabad on Monday.
PPP forms alliance with Khan's PTI
Senior PPP leader Sherry Rehman said that the party's doors are open to all political forces, when asked by BBC Urdu if the party was willing to work with PTI
However Mr Khan's media advisor, Zulfi Bukhari, told the BBC that it is highly likely for the PTI to sit on the benches of the opposition instead of forming a coalition if it fails to muster a majority.
This echoes the earlier sentiments of Mr Khan, who is currently serving a 14-year prison sentence on various charges. He said in 2018 that a coalition government would be weak and that the country needed a strong government to get through the crises it was facing. Nevertheless, he went on to form a coalition with smaller parties such as the MQM.
PML-N forms coalition with PTI and other parties
This would be a remarkable turnaround for a party whose leader has been jailed, its party symbol taken away and scores of its supporters detained. But in these unprecedented times, nothing can be ruled out.
The call of PML-N senior leader Azam Nazeer Tarar's for a "participatory coalition government" where "all should join hands, appears to be a tacit acknowledgement that the PTI cannot be ignored.
"Even those who didn't vote for Imran earlier may feel a sense of injustice over how the army has treated him and his party over the past two years," Georgetown University's Uday Chandra told the BBC. "A sense of democratic fairness, common across the region, seems to have been violated."
He added: "By picking Independents, voters are sending a clear message to the army: let civilian democracy prevail."
PTI-backed independents merge with smaller party
One possibility that has been mooted is that the PTI-backed candidates may join a smaller party in a bid to form a coalition government. This is in order to combine their seats, and also to capitalise on the 60 National Assembly seats reserved for women.
A political party gets one woman's reserved seat for every 3.5 seats it has won. Independent candidates are ineligible for this since they do not belong to a party. Within 72 hours of the election results being finalised, they must also declare their intention to either join a party or sit as an independent parliamentarian, reports BBC.
However Asma Faiz of the Lahore University of Management Sciences says it is "highly unlikely" that the PTI will be able to form a coalition government, as even alliances with smaller parties will still leave them short of a majority.
"For the PTI, there is no numerical advantage in reaching out to these miniscule parties except as a legal requirement to gain a foothold in a party," she said.