Former cricket star Imran Khan has declared victory in Pakistan’s parliamentary election and vowed to run the country “as it has never before been run” by fighting corruption, seeking regional cooperation and forging a new relationship with the US that was not “one-sided”.

TV stations reported Mr Khan and his Tehreek-e-Insaf party, or PTI, maintained a commanding lead from Wednesday’s voting.

But his leading rival, Shahbaz Sharif, rejected the outcome, citing allegations of vote-rigging.

Pakistan’s election commission struggled with technical problems and had to revert to a manual count, delaying the announcement of final results until Friday.

Pakistan Elections Khan the CricketerThis 1992 photo shows Imran Khan, second from right, captain of the Pakistan cricket team offering the World Cup to then prime minister of Pakistan Nawaz Sharif (AP)

That left it unclear whether the PTI will have a simple majority in the National Assembly or have to form a coalition government.

But that did not stop the 65-year-old Mr Khan from proclaiming his triumph in an address to the nation, in which he pledged to create an Islamic welfare state to provide education and employment for the poor to fulfil a campaign promise to create 10 million jobs.

“Today in front of you, in front of the people of Pakistan, I pledge I will run Pakistan in such a way as it has never before been run,” Mr Khan said.

He vowed to wipe out corruption, strengthen institutions he called dysfunctional and regain national pride by developing international relationships based on respect and equality.

While Mr Khan’s appeared casual and conciliatory in his speech, his words were laced with passion.

He said the United States treats Pakistan like a mercenary, giving it billions of dollars to fight the war on terrorism in a region beset with militant extremists.

“Unfortunately, so far our relations were one-sided. America thinks that it gives Pakistan money to fight for them. Because of this Pakistan suffered a lot,” said Mr Khan, who has been critical of the US-led conflict in neighbouring Afghanistan.

He offered nothing to suggest an improvement in Pakistan’s already testy relationship with Washington since President Donald Trump’s tweets in January that accused Islamabad of taking US aid and returning only lies and deceit.

Seeking good relations with his neighbours, Mr Khan addressed Pakistan’s rival, India.

The two nuclear powers have had a long-running conflict over the disputed region of Kashmir.

“Take one step toward us and we will take two steps toward you,” he said in a peace offering while still decrying widespread human rights abuses in Kashmir.

Mr Khan also advocated an open border policy with Afghanistan, even suggesting the two countries embrace a “European Union” type relationship.

The plan seems unlikely, with Pakistan’s military already building hundreds of border outposts and an accompanying fence along its western frontier with Afghanistan despite often-violent opposition from Kabul.

Pakistan ElectionsSupporters of Imran Khan celebrate his apparent victory (B.K. Banagsh/AP)

Mr Khan focused on what he wanted to do for the poor in Pakistan and his vision of a country that bowed to no one, where everyone was equal under the law and taxes were paid by the rich to fund services for the less fortunate.

His campaign message of a new Pakistan seemed to resonate with young voters in a country where 64 percent of its 200 million people are under 30.

Mr Khan said the elections were the most transparent and promised to investigate every complaint of irregularity that his opponents presented.

“It is thanks to God (that) we won and we were successful,” he said.

More than a dozen TV channels projected the PTI would win as many as 119 seats of the 270 National Assembly seats that were contested, although the broadcasters did not disclose their methodology.

The rest of the 342-seat parliament includes seats reserved for women and minorities.

Voting for two seats was postponed after one candidate died during the campaign and another was disqualified.

Pakistan ElectionsImran Khan casts his vote (Anjum Naveed/AP)

Although rights groups and minorities expressed worries ahead of the voting about radical religious groups taking part, moderate voices seemed to have prevailed: none of the 265 candidates fielded by the outlawed Lashkar-e-Taiba won.

That includes the son of co-founder and US-designated terrorist Hafiz Saeed, who has a 10 million US dollar bounty on his head.

The candidates campaigned under the little known Allah-o-Akbar Tehreek party because Lashkar-e-Taiba is banned.

Even if Mr Khan’s party wins a simple majority, he would need to wait until the president convenes the parliament to swear in the new politicians, traditionally within a week.

He also faces opposition over the result from Mr Sharif.

He heads the Pakistan Muslim League, the party of his older brother, former prime minister Nawaz Sharif, who is in prison on corruption charges.

TV projections give his party barely 61 seats.

Pakistan ElectionsPeople listen to Imran Khan’s speech (Anjum Naveed/AP)

The younger Mr Sharif tweeted that “our democratic process has been pushed back by decades”, adding that “had the public mandate been delivered in a fair manner, we would have accepted it happily”.

Complaints also emerged from the independent Human Rights Commission, which issued a statement saying that women were not allowed to vote in some areas.

In other areas, it said, “polling staff appeared to be biased toward a certain party,” without elaborating.

In the days before the election, leading rights activist I.A. Rehman called the campaign “the dirtiest” in Pakistan’s bumpy journey toward sustained democracy.

Analysts have expressed concern that disgruntled losers could create instability for the incoming government, which must deal with a crumbling economy, crippling debt and a raging militancy.

The voting was marred by a suicide bombing in the southwestern city of Quetta, the Baluchistan provincial capital, that killed 31 people as they waited to vote.

A bombing in the same province earlier this month killed 149 people, including a candidate for office.

Baluchistan has been hit by relentless attacks, both by the province’s secessionists and Sunni militants who have killed hundreds of Shiites there.

The election marked only the second time in Pakistan’s 71-year history that one civilian government has handed power to another.