Pakistan has elected Mamnoon Hussain, backed by the ruling Pakistan Muslim League-N party (PML-N), as its 12th president, state TV has said.

Legislators from both houses of the national parliament and four provincial assemblies voted on Tuesday in the two-man race for the largely ceremonial post as president.

Hussain, a 73-year-old businessman-turned politician, will replace Asif Ali Zardari of the opposition Pakistan People's Party (PPP), whose five-year term expires in September.

Within minutes of the polls closing at 3pm local time, state media handed the vote to Hussain, based on unofficial results. The final tally is expected to be announced by the evening.

Hussain, a close ally of Prime Minister Nawaz Sharif in Pakistan's financial capital Karachi, had been considered certain to replace Zardari.

The PPP, which lost heavily in general elections in May, boycotted Tuesday's ballot over complaints that the vote was brought forward from August 6.

Low profile

The only other candidate was retired Supreme Court judge Wajihuddin Ahmed, nominated by the Pakistan Tehreek-e-Insaf, the third largest party in parliament and led by cricket-turned politician Imran Khan.

Hussain's loyalty to Sharif and low profile is expected to bolster the prime minister's authority and provide a stark contrast to Zardari, considered a sharp political operator behind the scenes.

A long-serving member of the ruling PML-N party, he briefly served as governor of the southern province Sindh under Sharif's last stint as prime minister in 1999.

Hussain is a former president of the Karachi Chamber of Commerce and Industry (KCCI).

Sharif won a commanding general election victory in May, which marked the first time a Pakistani civilian government completed a full term in office and handed over to another at the ballot box.