Polls were marred by militant violence, political turmoil, and questions of transparency.

Former prime ministers and bitter rivals Nawaz Sharif and Imran Khan both declared victory, adding to the sense of uncertainty on the streets.

Local businessman Waseem Qureishi:

"I don't think the elections were fair. I think the results were tampered with. Any government that is formed as a result of such circumstances cannot last for more than a year, or a year and a half, or maximum two years."

Pakistan's next leader will face urgent challenges, including negotiating a new International Monetary Fund program to keep a struggling economy afloat.

And staying on the right side of a powerful military that has deposed previous leaders.

Next - any prime ministerial candidate must show a simple majority of 169 seats in the National Assembly.

Here are the main scenarios to break the deadlock:

Khan, a charismatic opposition leader and former cricket star, is in jail and not eligible to become prime minister.

His supporters had to run as independents and they were the biggest winners with 93 seats.

Political analyst Amir Zia:

"They cannot operate as a political party within the parliament. So the choice before them is: either they form a separate new group or they joined some other political party. So it is yet to be seen what's going to happen to them."

They might try to strike a deal with other parties to support a consensus candidate.

In power, Khan's supporters would try to have their jailed leader released under an agreement.

Sharif was considered the frontrunner by analysts, who say the powerful military backs him.

His party is the largest in parliament, winning 75 seats.

It is now seeking a coalition with other groups.

AMIR ZIA: "We see that there will be a coalition government which is going to shape up in the coming days and weeks, but I expect very hard bargaining from all the political players. Everyone would like to have their pound of flesh..."

A likely partner is the party of political scion Bilawal Bhutto Zardari, the son of assassinated former premier Benazir Bhutto.

His Pakistan Peoples Party won the third-largest number of votes.

The two parties were in government together for 16 months till August.

But what if there's no deal and uncertainty drags on?

Pakistan's army, the most powerful and organized force in the country, would likely take power.

It has done this three times before in the country's 76-year history - the last time in 1999 to overthrow Sharif's government.

The army has already called on political parties to show "maturity and unity."

No Pakistani prime minister has ever served a full term.