It has been a difficult few days for the party that used to run Pakistan.First, the party, the Pakistan Muslim League-Nawaz, known as the P.M.L.-N., came a distant second in the national election, winning about half as many parliamentary seats as the party headed by Imran Khan, a former cricket star.
Then Nawaz Sharif, the party’s figurehead and a former prime minister who was jailed by an anticorruption court , was rushed to a hospital because of chest pains.
It appeared as if the party could lose another piece of its empire: the provincial assembly in Punjab, regarded as the silver medal of Pakistani politics.
Mr. Khan, whose campaign was said to have been backed by the military, is still trying to gather enough support to form a majority coalition in the national Parliament. But, the influential newspaper Dawn was already calling him the prime minister in waiting.
While the national politics are being sorted out, Mr. Khan’s party has opened a second front in Punjab, the nation’s richest and most populous province, home to the cities of Lahore and Rawalpindi and more than half of Pakistan’s 200 million people.
Lawmakers in Punjab wield huge power over education, law enforcement and billions of dollars in development funds. The province is considered the cultural heart of the country and enormously influential.
Mr. Khan’s party, the Pakistan Movement for Justice, won fewer provincial seats in Punjab than the P.M.L.-N., but over the weekend Mr. Khan persuaded several independent politicians to join his side. Though the P.M.L.-N. has also been wooing independents, analysts said that as night, Mr. Khan’s party maintained a slight edge.
Both the national Parliament and the Punjab legislature have been controlled for years by the P.M.L.-N., which in turn was dominated by Mr. Sharif. But he frequently clashed with another powerful player, the military, which has ruled Pakistan for much of its 70-year history either directly or through interference in political affairs.
Rights groups, academics and other observers have said that leading up to the July 25 election, military and security officials targeted members of the P.M.L.-N. and other parties so that Mr. Khan could cruise to victory. They also say the military pressured the courts to remove Mr. Sharif from office last year and convict him in a corruption case.
In the ruling that ousted Mr. Sharif from office last year, the Supreme Court concluded that he and his family members could not explain how they were able to afford several expensive London apartments and that they had failed to provide a money trail.
Analysts say his subsequent prosecution was timed to do the most damage to his party.
Mr. Sharif, 68, who is serving a 10-year prison sentence in Rawalpindi, was moved to a hospital in Islamabad, the capital, after being examined by doctors. Two years ago, he had open-heart surgery in London, and he has diabetes and kidney problems. As he was sped through the hospital gates on Sunday, dozens of party workers who had gathered to show their support and affection shouted out, “We love you!”
His appeal has been scheduled, and his lawyer said that conditions at the prison and the stress of the electoral defeat had contributed to his deteriorating health.
“This has been very hard on him,” said the lawyer, Khawaja Haris, who was poring over a stack of highlighted legal documents on Monday afternoon in an Islamabad hotel.
Despite the alleged military support, Mr. Khan’s party fell short of an outright majority, and his bid to form a government has been complicated by his own success.
Mr. Khan ran personally for five seats and won them all, which the Pakistani news media said was unprecedented. But while candidates are allowed to run for multiple parliamentary seats in the same election, they can hold only one.
So Mr. Khan now has to relinquish four of his five seats; special elections will be scheduled in the coming months to fill the vacancies. The upshot is that his party will have at least four fewer votes in Parliament when it comes time to select a prime minister.
This, on top of a flurry of recount requests, could mean his party might not be as dominant as initially believed. Still, most analysts predict that Mr. Khan, who struggled for years to build a political following while transforming himself from an elite socialite into a populist figure, will prevail.
“I have absolutely no reason to believe that anyone else will be the prime minister of Pakistan other than Imran Khan,” said Sohail Warraich, a well-known political commentator and author.
Jockeying for support in Parliament is typical after an election, he said, and the prospect of proximity to power would entice enough independent politicians and smaller parties to join Mr. Khan.
The Pakistan Movement for Justice is already planning Mr. Khan’s swearing-in, promising it will be “a people’s ceremony.”
Fawad Chaudhry, a spokesman for Mr. Khan’s party, claimed that it had found the votes it required both in Parliament and in the Punjab legislature. “We have attained the numbers,” Mr. Chaudhry said.
A few days ago, some of the losing parties, furious about the military’s hand in the election, had threatened to stage street protests, and some candidates had even talked of boycotting Parliament and not taking their seats. But those threats seemed to be becoming more tempered, even as several rival parties gathered in Islamabad to discuss a joint protest strategy over what they claim was massive rigging in the general election.
“We demand that the whole election commission should resign,” Raja Zafarul Haq, a senior P.M.L.-N. leader, said after the meeting.
“We reject these rigged elections,” said the former prime minister Yousaf Raza Gilani, a leader of the Pakistan Peoples Party, traditionally the P.M.L.-N.’s main competitor.
The rival parties say they will hold more rounds of consultations to reach a decisive course of action. But all have agreed to take their seats in the Parliament.
“There is no doubt the elections were systematically rigged,” said Qaisar Sharif, a spokesman for an Islamist political party. “But the country is not in a situation to face street protests.”
He, too, seemed to accept that Mr. Khan would be the next prime minister, using a common shorthand for Pakistan’s military and intelligence services.
“The establishment made them win the elections,” he said. “Therefore, the establishment will ensure Imran gets the number to become the P.M.”