Zimbabwe's electoral commission declared Emmerson Mnangagwa president with a 50.8 percent of the vote. Opposition protesters have accused the ruling party of trying to rig the election.
The electoral commission announced the presidential election results province by province late on Thursday night and declared Mnangagwa president shortly after midnight with 2.46 million votes against 2.15 million for his rival Nelson Chamisa.
Mnangagwa led Chamisa by some 230,000 votes after nine of the ten provinces had been declared. Mnangagwa had 53 percent or 2.15 million votes counted over Chamisa's 47 percent or 1.92 million votes.
After the first four of ten provincial results, Chamisa's opposition Movement for Democratic Change (MDC) had a lead of about 50,000 votes over the ruling ZANU-PF but after the fifth province was announced, the lead had switched to Mnangagwa.
When the final province was reported, Mnangagwa's share of the vote was declared at 50.8 percent by the electoral commission.
Chamisa's share was 44.3 percent of the total vote.
To become president, a candidate has to take more than 50 percent of the vote. Chamisa did well in urban areas but Mnangagwa outperformed him in rural zones.
The announcement came after clashes between opposition protesters and soldiers in Harare left at least six people dead. The unrest marred what had been billed as an important milestone in Zimbabwe's efforts to return to democracy following 37 years of repression under longtime leader Robert Mugabe.
Chamisa said police raided opposition headquarters in Harare and seized computers. The search warrant indicated they were looking for unlicenced firearms, grenades and stones. Police said 16 people in the offices were arrested.
Results announced by the electoral commission:
Mnangagwa was declared president with 50.8 percent of the vote to Chamisa's 44.3 percent.
The ruling ZANU-PF party won 144 of the 210 seats in parliament -- a two-thirds majority that enables it to change the constitution.
The opposition Movement for Democratic Change (MDC) took 61 seats.
The electoral commission was yet to announce three undeclared seats.
Mnangagwa called for an independent investigation into the deadly unrest in Harare and said that he had spoken with opposition leader Nelson Chamisa to try to defuse tension.
"We must maintain this dialogue in order to protect the peace we hold dear," he wrote Thursday on Twitter. "Together we must lead by example and show all Zimbabweans that peace is paramount."
Late Wednesday, Chamisa, 40, said the presidential results were bound to be fraudulent, telling his supporters: "We have won this one together. No amount of results manipulation will alter your will."
Elmar Brok, chief observer for the EU's election monitor mission in Zimbabwe, told DW that the vote was marred by a "lot of shortcomings in favor of the ruling party," including through "financing, state media, intimidation, especially in the countryside."
Zimbabwe Electoral Commission chairwoman Priscilla Chigumba denied allegations of bias and strongly disputed accusations of rigging.