Updated

Pakistani lawmakers on Friday elected former cricket star and longtime politician Imran Khan as the country's next prime minister, in a step toward the country's third civilian transfer of power.

In the vote at the National Assembly, Khan secured 176 votes, defeating the opposition's candidate, Shahbaz Sharif of the Pakistan Muslim League party, who got 96 votes.

The populist Tehrik-e-Insaf party won the most seats in the July 25 vote but fell short of securing a majority in the 342-seat house.

Khan is to be sworn in as prime minister on Saturday. His mandate lasts five years.

His supporters celebrated across the country when Speaker Asad Qaiser announced result.

Khan is a former Oxford graduate and formed his party in 1996 in the eastern city of Lahore, vowing to forge a "new Pakistan" that would be corruption free and with justice for all without discrimination.

He challenged the parties of Sharif and former President Asif Ali Zardari over the past two decades. He was not able to make a strong showing until 2013, when his became the third-largest party in the lower house of parliament. He was finally able to triumph over his opponents them in last month's vote.

Sharif is the younger brother of former Prime Minister Nawaz Sharif, who is serving a ten-year jail term in a corruption case.

The elder Sharif, who served as Pakistan's prime minister three times, was disqualified last year by the Supreme Court for concealing his assets abroad. Later, an anti-court tribunal convicted and sentenced Sharif to ten years in jail over family's purchase of luxury apartments in London.

Khan acquired a reputation as somewhat of a playboy during his cricketing years but has since embraced conservative Islam after entering politics.

In his 2011 book "Pakistan: A Personal History," Khan noted that his ambition to come to power when his Islamic nation held free and fair elections.

Aside from tackling corruption, and a vision to introduce "surgical reforms" in governance, one of the key challenges now facing Khan is how to improve ties with the United States.

Khan was elected as Pakistan's new premier a day after the Foreign Ministry confirmed the suspension of a U.S. military training program for Pakistani soldiers. Thursday's announcement underscores the persistent tensions between the two allies in the war on terror.

The program is the latest to suffer from cuts to U.S. security aid to Pakistan, announced at the beginning of this year. The U.S. accuses Pakistan of harboring militant groups and providing safe havens for insurgents who carry out attacks in neighboring Afghanistan, a charge Islamabad denies.

Pakistan also repeatedly reminds the U.S. that it has lost thousands of soldiers — more than the U.S. and NATO in Afghanistan combined — in its fight against militants in its territory.