By Idrees Ali and Saad Sayeed
ISLAMABAD (Reuters) - Pakistani cricket legend Imran Khan declared victory on Thursday in a divisive general election, and said he was ready to lead the nuclear-armed nation despite a long delay in ballot counting and allegations of vote-rigging from his main opponents.
His success in Wednesday's election is a stunning rise for an anti-corruption crusader who has spent much of his political career on the fringes of Pakistan politics, but now stands on the brink of becoming the country's prime minister.
"God has given me a chance to come to power to implement that ideology which I started 22 years ago," Khan, 65, said in a televised speech from his house near the capital Islamabad.
Graphic - Pakistan Election: https://tmsnrt.rs/2LaIlGt
Supporters of jailed former Prime Minister Nawaz Sharif, who accuse Khan of colluding with the still powerful army, said the vote count was rigged in what it termed an assault on democracy in a country with a history of military rule.
Oxford-educated Khan, in the past a fierce critic of U.S. policy in the region, called for "mutually beneficial" ties with Pakistan's on-off ally the United States, and offered an olive branch to arch-foe India, saying the two nations should resolve their long-simmering dispute over Kashmir.
In a speech peppered with populist pledges, Khan promised to create jobs for the poor and said he would turn the palatial prime minister's official residence in the capital into an education facility instead of living in it.
With about half the votes counted, Khan's Pakistan Tehreek-i-Insaf (PTI), or Pakistan Movement for Justice, had a wide lead in the Muslim-majority nation, the country's election commission said.
Sharif's Pakistan Muslim League-Nawaz (PML-N) and rival Pakistan Peoples Party (PPP) both said their party monitors at many voting centres were either kicked out during counting or had not received the official notifications of the precinct's results, instead being given handwritten tallies they could not verify.
"It is a sheer rigging. The way the people's mandate has blatantly been insulted, it is intolerable," Shehbaz Sharif, PML-N president and Nawaz's brother, told a news conference.
Khan has staunchly denied allegations by PML-N that he is getting help from the military, which has ruled Pakistan for about half of its history and still sets key security and foreign policy.
The army, which dismisses allegations of meddling, deployed 371,000 soldiers at polling stations across the country, nearly five times the number as in last election in 2013.
Khan offered to investigate all the allegations of rigging and said he wants to "unite" the country under his leadership.
Pakistan faces a mounting economic crisis that is likely to require a bailout from the International Monetary Fund, the likely conditions of which could complicate Khan's spending pledges. PTI has also not ruled out seeking succour from China, Islamabad's closest ally which has in recent years been investing heavily in infrastructure in the country.
Election Commission of Pakistan (ECP) secretary Babar Yaqoob told reporters early on Thursday that counting had been delayed by technical failures in an electronic reporting system and the tallying was now being conducted manually. The results had been due by around 2 a.m. (2100 GMT on Wednesday).
By early Thursday evening, a full day after polls closed, he told reporters 82 percent of results had been received and rejected the allegations of tampering in the vote count.
"The complaints we have been receiving, they could be of procedural level, but not any kind of rigging," Yaqoob said.
With 48 percent of the total vote counted, Khan's PTI was listed by the ECP in its provisional results as leading in 113 of 272 contested National Assembly constituencies.
Sharif's PML-N was ahead in 64 constituencies, and the PPP, led by Bilawal Bhutto Zardari, the son of assassinated two-time prime minister Benazir Bhutto, led in 42 constituencies.
Although Khan still appeared likely to fall short of the 137 seats needed for a majority in the National Assembly, he should have no problems finding coalition partners from smaller parties and independents.
Pakistan's election monitoring body and the European Union's were scheduled to deliver their assessments of the conduct of the election on Friday.
An icon of Pakistani cricket and a one-time London playboy who has since transformed himself into a pious, firebrand nationalist, Khan's campaign speeches were littered with anti-America rhetoric and baiting of India.
But in his victory speech, Khan pledged to improve ties with Washington and Pakistan's neighbours at a time the country is becoming increasingly isolated over its alleged links with Islamist militants in Afghanistan.
He called for a "balanced relationship" with the United States, which has taken a firmer line on Pakistan under President Donald Trump, suspending aid and even convincing Western allies to put Pakistan on a terror financing watchlist earlier this year.
Quipping that Indian media had recently portrayed him like a "villain in a Bollywood movie", Khan's overtures to New Delhi included calls for better trade ties and to sit down and discuss Kashmir, a disputed region that was the cause of two of the three wars between the neighbours.
Khan also said he wants deepen ties with old ally Beijing and emulate China's success in reducing poverty.
Investors welcomed Khan's election success, with Pakistan's benchmark 100-share index surging as much as 1.9 percent to 42,136 points in early trade, before closing 1.8 percent up. Analysts said there was relief Khan was unlikely to have to rely on major opposition parties in a messy coalition.
Khan has promised an "Islamic welfare state" and cast his campaign as a battle to topple a predatory political elite hindering development in the impoverished nation of 208 million, where the illiteracy rate hovers above 40 percent.
"Accountability will start with me, then my ministers, and then we will work our way down," Khan said. "I want all of Pakistan to be united in this moment."
(Additional reporting by Kay Johnson and Asif Shahzad in Islamabad, Syed Raza Hassan in Karachi. Writing by Drazen Jorgic; Editing by Raju Gopalakrishnan and Alex Richardson)