But he refused to say what he would do if the supreme court overturns the result, adding: "Let them come to their decision, then we will decide."
In the two houses of parliament, Musharraf won 252 of 257 votes, and also won the most votes in three of four provincial assemblies, officials said.
About 30 per cent of national assembly opposition politicians resigned before the vote and Benazir Bhutto's Pakistan People's Party abstained.
A rival, Wajihudduin Ahmad, a former judge who refused to swear allegiance to Musharraf after the coup that brought him to power in 1999, got two votes. Three votes were rejected.
Ahmad told Al Jazeera that there was a good chance the supreme court would not endorse Musharraf's victory.
"We have a very strong case," he said.
Musharraf's total electoral college vote, including the provincial assemblies, was 384 ballots out of 702, government officials said
Musharraf has been in conflict with the supreme court since he attempted to sack Iftikhar Muhammad Chaudhry, the chief justice.
However, Ayaz Amir, a Pakistani political columnist, told Al Jazeera that Pakistanis were very cynical about the validity of the poll.
"People are taking this election with a large bucketful of salt, " he said.
Earlier, anti-government protests, led by lawyers, who have spearheaded a campaign against Musharraf in recent months, took place in Karachi, Lahore, Peshawar and Quetta.
Police fired tear gas to disperse lawyers pelting rocks at the North West Frontier Province assembly, and the lawyers also threw a burning effigy of the president on top of an armoured police vehicle.
|Musharraf appealed to Pakistanis in|
a televised address [AFP]
Before election officials announced the result, Wajiha Mehdi, a lawyer and associate of Chaudhry, told Al Jazeera she believed that any win for Musharraf would be unconstitutional.
"The people of Pakistan are now going to speak. They have had enough."
However, Amir said it was unlikely that the supreme court would overturn Musharraf's victory.
If his re-election is confirmed, the president has promised to leave his position as head of the army by November 15 and be sworn in as a civilian leader.
Opposition parties have vowed to stage protests over Musharraf's decision not to step down from his army post ahead of the election.
"Pakistan needs a military leader who can control both civil and possible military extremism"
Creative_person01, Islamabad, Pakistan
Send us your views
But Musharraf had averted a walk-out by Bhutto's PPP by granting her amnesty from corruption charges, paving the way for a power-sharing deal between the two politicians.
Bhutto, whose party is the country's largest, had earlier threatened to further undermine Musharraf's widely anticipated victory by pulling her MPs from parliament, after other opposition parties also resigned.
The amnesty clears the way for her planned homecoming on October 18 in the run-up to parliamentary elections due by early 2008.