Pakistan on Tuesday elected a close ally of Prime Minister Imran Khan as its new president, further cementing the ruling party's power after a general election victory.
Former dentist Arif Alvi, one of the founders of Khan's Pakistan Tehreek-e-Insaf (PTI) party, will replace Mamnoon Hussain after the vote by more than a thousand lawmakers from both houses of parliament and the four provincial assemblies.
Former cricket champion Khan became prime minister last month following his party's victory in the mid-July parliamentary elections.
State-run Pakistan television announced the unofficial results just over an hour after voting ended on Tuesday, with Alvi claiming victory in televised remarks.
"According to unofficial results, Alvi bagged 353 votes," election commission spokesman Altaf Ahmad later told AFP.
Alvi's opponent Maulana Fazlur Rehman of Jamiat Ulema-e-Islam, an opposition party backed by the ousted Pakistan Muslim League-Nawaz (PML-N), came second with 185 votes while Pakistan Peoples Party (PPP) candidate Aitzaz Ahsan won 124 votes, Ahmad said.
The official result is expected to be announced by the election commission on Wednesday.
Alvi told reporters he was "thankful to God", and vowed to be a president for all of Pakistan. TV footage showed him shaking hands with parliamentarians after the vote, with many handing him sweets in celebration.
A father of four and active Twitter user, Alvi was shot and wounded during a protest against military dictator Ayub Khan in Lahore in 1969. He still has a bullet embedded in his right arm.
He studied at the University of Michigan and the University of the Pacific in San Francisco, as well as in Lahore, before making a career as a dentist and then entering politics.
He served as PTI's secretary general for eight years from 2006, and was elected an MP in the southern megacity of Karachi in 2013, winning re-election in the July vote.
Pakistani presidents wielded more power until President Asif Ali Zardari, the husband of assassinated premier Benazir Bhutto, took office in 2008 and devolved most of his powers to his prime minister Yousaf Raza Gilani.
Political analyst Sohail Warraich said the president's role is now to act as a bridge between the federal government and the provinces, adding that Alvi's status as a member of middle-class Pakistan would endear him further to Khan.
"In Pakistan, middle-class presidents don't revolt against prime ministers," he said.
Khan's government now faces major challenges, with the country teetering on the edge of a balance-of-payments crisis that analysts say could force it to seek an IMF bailout.
Pakistan is also among the world's worst affected countries by global warming, and is facing a shortage of water exacerbated by its surging population.