Former cricket star Imran Khan has been elected prime minister of Pakistan in a vote at the country's National Assembly.
His PTI party won the most seats in July's elections - setting up Mr Khan to become PM with the help of small parties, more than two decades after he first entered politics.
He will be sworn in on Saturday.
Mr Khan, 65, will inherit a country with a mounting economic crisis and he has vowed to create a "new Pakistan".
The charismatic sports star, who captained Pakistan to a World Cup victory in 1992, has long shed his celebrity playboy image and now styles himself as a pious, populist, anti-poverty reformer.
He ran on an anti-corruption platform that pledged to improve the lives of the country's poor with an "Islamic welfare state".
In Friday's vote, Mr Khan was backed by 176 National Assembly members. His opponent, Pakistan Muslim League-Nawaz (PML-N) president Shehbaz Sharif, received 96 votes.
Speaking after the results were revealed, the prime minister-elect vowed to bring about the "change that this nation was longing for", according to local media.
He promised "strict accountability" for those who had "looted this country".
"I did not climb on any dictator's shoulders; I reached this place after struggling for 22 years."
Before the election Mr Khan told the BBC that if he were to be elected, his initial focus would be on the economy. Pakistan's currency, the rupee, has declined significantly in the last year. Inflation is on the rise and the trade deficit is widening.
Exports such as textiles have taken a hit from cheaper products by regional competitors, including China. Analysts say the new government may need to turn to the International Monetary Fund (IMF) for the country's second bailout since 2013, which could complicate efforts to boost welfare.
After the 25 July election, Mr Khan also vowed to hold talks with India to seek a resolution to the dispute over the Kashmir region, a key flashpoint between the nuclear-armed countries.
He also called for "mutually beneficial" ties with the United States, despite being an outspoken critic of that country's anti-terrorism measures in the region, such as drone strikes. US President Donald Trump recently cut aid to Pakistan, accusing it of providing a "safe haven" to terrorists active in neighbouring Afghanistan.
Opposition parties have claimed elements of last month's elections were rigged, but they agreed to take their seats in the assembly.
In the lead-up to the election, Mr Khan was widely seen as the favoured candidate of the powerful military, which was accused of meddling against his rivals.
Three-time Prime Minister Nawaz Sharif was ousted from office in 2017 over corruption allegations.
He was jailed in the lead-up to the vote, and his brother, Shahbaz Sharif, led the PML-N party into the election.
After the election, three major opposition parties banded together to nominate Shahbaz Sharif as a joint candidate in a bid to thwart Mr Khan.
However, one of the parties - the PPP party of assassinated ex-Prime Minister Benazir Bhutto - is reported to have withdrawn its support for Mr Sharif in the run-up to the vote and abstained on Friday.
The PPP and PML-N have dominated Pakistani politics for decades, governing several times in between periods of military rule.