ISLAMABAD -- For Pakistani cricket legend-turned-politician Imran Khan, his party's first place in a national election, putting him on the brink of becoming the country's next prime minister, is the culmination of a battle that started more than two decades ago.
For years, he was dismissed as a political dilettante who could not convert his personal popularity into significant seats in parliament for the Pakistan Tehreek-i-Insaf (PTI), or Pakistan Movement for Justice, he founded.
But Wednesday's election has dramatically changed that, putting the former sports star on the brink of power. With nearly half the votes counted, PTI held a commanding lead and Khan declared victory in a speech on Thursday.
Khan could join George Weah, one of Africa's greatest footballers who took over as president of Liberia earlier this year, as the only other international sports personality to head his country's government.
As prime minister, Khan, 65, would be tested on several fronts, from dealing with an urgent foreign currency shortage to managing a tense relationship with the United States.
"I don't discount the role that experience in sports leadership can translate into other domains," said Sameer Lalwani, co-director of the South Asia program at the Stimson Center think tank.
"(But) he has never had to govern... I worry that what we've seen about his public profile and the way he portrays himself, that he is much more likely to surround himself with sycophants."
Khan will also have to battle allegations that he has been helped by Pakistan's powerful military both during the campaign and in the vote count - rival parties have said soldiers at voting centres threw out their observers when counting began.
Khan promised to investigate voting complaints, but has said those who accuse him of military help are trying to preserve a corrupt system. The army, which has ruled the country for almost half its history, denies interfering in politics.
An Oxford graduate, Khan campaigned hard on populist promises of a prosperous Pakistan that breaks away from its persistent legacy of corruption.
Before the advent of PTI, Pakistani politics had been dominated by two parties - former Prime Minister Nawaz Sharif's Pakistan Muslim League-Nawaz and the Pakistan People's Party of assassinated former leader Benazir Bhutto - when the military has not been in power.
Khan began his cricket career in 1971 as a fast bowler known for his pace and aggressive tactics. By the time he retired more than 20 years later, he was regarded as one of the world's best ever all-rounders.
A glamorous fixture of London's high society in his younger days, he was captain of Pakistan's team of talented but wayward stars and - with a reputation as a stern taskmaster - led them to win cricket's World Cup for the first time in 1992.
He is still known as "Kaptaan" (captain) in Pakistan.
After his retirement, Khan raised funds to open a cancer hospital in the memory of his mother in his native Lahore in 1994.
He has mostly shed the playboy image and made public shows of devotion to Islam, building a large political following in northern Pakistan, especially with the conservative Pashtun population.
Earlier this year, he married his spiritual adviser. Khan's previous two marriages, particularly when he wed his first wife, British heiress Jemima Khan, had captivated international tabloids.
Khan started the PTI in 1996, but until 2013 it briefly held only one seat in parliament.
"It's been a 22-year struggle for justice for the people of Pakistan," Khan told Reuters in an interview earlier this month.
His party became the country's third-largest in the National Assembly in the previous election, benefiting in part from a groundswell of support, especially from young, urban voters fed up with the country's corruption.
RELATIONS WITH WASHINGTON
Khan has been critical of the United States' policy in the region and vocally opposed drone strikes on Pakistani territory.
He would have to manage a tense relationship with Washington, which has accused Islamabad of not doing enough to root out Taliban militants.
Earlier this year, President Donald Trump tweeted that the United States had "foolishly" given Pakistan more than $33 billion in aid.
Khan opposes the United States' open-ended presence in Afghanistan. In his victory speech on Thursday, he said he wanted "mutually beneficial" relations with Washington, and peace in Afghanistan.
"I do think he will be publicly more adversarial.. (But) he is certainly capable of being more pragmatic, that just hasn't served his purposes in campaigning and branding himself," said a former senior U.S. official, who has met Khan several times.
The official, speaking on the condition of anonymity, said Khan's stance on the United States would likely be moderated by Pakistan's powerful military, which seeks a more stable relationship with America.
Khan will also have to urgently resolve a currency crisis that threatens Pakistan's fast-growing economy, which expanded by 5.8 percent in the past year but will most likely need its second bailout from the International Monetary Fund (IMF) since 2013.
He has said his future government will launch an anti-corruption campaign and poverty reduction program modelled on China, Pakistan's traditional ally that has financed billions of dollars of infrastructure projects.
At the same time, he has promised to build an "Islamic welfare state", create 10 million jobs and build 5 million homes for the poor.
Asked how he would fund such social spending, Khan has vowed to double Pakistan's woefully low tax collection rates - the country has one of the world's lowest tax-to-GDP ratios - by reforming the "corrupt" Federal Bureau of Revenue.
"Instead of making policies for a small elite, we will make all policies for this poor class, the oppressed class," he said on Thursday.