Asif Ali Zardari says his win was a victory for democracy
Asif Ali Zardari, the widower of former Prime Minister Benazir Bhutto, has won a sweeping victory in Pakistan's presidential election.
The election was called after Pervez Musharraf resigned rather than risk being impeached.
Mr Zardari faces severe economic problems and a rampant Islamist insurgency that is threatening Pakistan's stability.
During the voting, a bomb killed at least 30 people near Peshawar city.
The president is elected by secret ballots in the national and four provincial assemblies.
Mr Zardari won 481 votes out of 702, far more than the 352 votes that would have guaranteed him victory, leaving his two rivals trailing far behind.
In Sindh province, Mr Zardari won all 65 votes. In North West Frontier Province (NWFP) he got 56 out of the 65 votes. In Balochistan province he won 59 of the 65 votes.
By contrast he only won 22 out of 65 seats in Punjab province, the heartland of former Prime Minister Nawaz Sharif's PML-N party.
The two daughters of Mr Zardari and Ms Bhutto hugged friends in delight in the gallery of the national assembly as the results became clear. Members of Mr Zardari's Pakistan People's Party (PPP) declared the result to be a "victory for democracy".
Mr Zardari was thrust into the centre of political power by the killing of Ms Bhutto last December after which he became head of the PPP.
The BBC's Barbara Plett in Islamabad says that in recent months Mr Zardari has shown skill by forging a large coalition and using it to peacefully unseat President Musharraf.
Mr Zardari is one of Pakistan's most controversial politicians.
For years he has been hounded by allegations of massive corruption - although he has never been convicted.
Former Prime Minister Nawaz Sharif took his PML-N party out of the governing coalition last week, accusing Mr Zardari of breaking key promises.
Many in Pakistan fear the country is facing a return to an old-style politics of confrontation at a time when urgent action is needed to improve the economy and deal with a raging Islamist insurgency.
Mr Zardari is seen as pro-Western and supportive of Washington's self-declared war on terror. He will have to juggle the demands of the United States, Pakistan's powerful army, and strong anti-American sentiment in the country.
Nawaz Sharif's coalition with Mr Zardari did not last long
Our correspondent says Mr Musharraf tried to do that and failed. She adds that Pakistanis hope that Asif Zardari will have more success, but they see little in his past to encourage them.
The fortunes of the Bhutto-Zardari family have fluctuated dramatically.
Mr Zardari spent years in prison while Gen Musharraf ruled Pakistan. Benazir Bhutto was assassinated at an election rally in December. Her father, Zulfiqar Ali Bhutto, was hanged during the military dictatorship of President Ziaul Haq.
A further reminder of the dangers of public life in Pakistan came on Wednesday when gunmen attacked the motorcade of the prime minister. Two bullets hit his car, although he was not in it at the time officials say.
The other candidates for the presidency were Saeeduz Zaman Siddiqui, a former judge who had the backing of Mr Sharif, and Mushahid Hussain Sayed, who was nominated by the PML-Q party that supported Mr Musharraf.
In the Islamabad parliament, members of the upper house, the Senate, were due to vote first, followed by the lower house.
Pakistan's four provincial assemblies of Sindh, Punjab, Balochistan and the NWFP had a similar schedule.
However, voting in the NWFP capital, Peshawar, was delayed when a 5.6 magnitude earthquake hit the area and neighbouring Afghanistan, prompting deputies to flee the assembly building.
The provincial assemblies are given equal weighting with 65 votes each. In the three assemblies which do not have 65 deputies, the value of each deputy's vote is adjusted by a mathematical formula.
There is only one round of voting and whoever has most of the 702 votes wins.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.