The commission announced the presidential election results province by province, declaring Mnangagwa president by the closest of margins shortly after midnight Friday.

According to the commission, Mnangagwa won 50.8 percent of the vote, ahead of Nelson Chamisa of the opposition Movement for Democratic Change (MDC) party on 44.3 percent.

After the first four of ten provincial results, Chamisa’s 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. He quickly took to Twitter to hail what he called “a new beginning.”

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 among rural voters.

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.

However, the opposition has accused the ruling party of trying to rig the election.

The opposition indicated it would challenge the result in the courts. “What they have been trying to do of late is to play around,” Chamisa told reporters hours before the final results. “That is rigging, that is manipulation, trying to bastardise the result, and that we will not allow.”

Supporters of the MDC burn a campaign poster with the face of Emmerson Mnangagwa

Supporters of the MDC burn a ZANU-PF party campaign banner in Harare

Other results announced by the electoral commission:

The ruling ZANU-PF party won 144 of the 210 seats in parliament — a two-thirds majority which 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.

President Mnangagwa called for an independent investigation into the deadly unrest in Harare and said that he had spoken with opposition leader 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.”

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.”

After withholding official results for four days, Zimbabwe’s election commission on Friday declared Emmerson Mnangagwa the winner of the July 30 presidential vote. The former ally of ex-President Robert Mugabe, Mnangagwa won 50.8 percent of the vote. Zimbabwe’s opposition said the results were “fake” and vowed to protest.

Post-Mugabe vote: Under former President Robert Mugabe, 94, the country went from being a prosperous economy to a pariah state wrecked by mismanagement and corruption. Elections during his rule were largely marked by repression and fraud allegations. His successor, Emmerson Mnangagwa, had promised a free and fair vote, inviting EU observers for the first time since 2002.

Who is Emmerson Mnangagwa?

Mugabe’s former deputy president and right-hand man was the clear favorite to win the presidential race. Sometimes dubbed “the crocodile” for his ruthlessness during his years as Mugabe’s state security chief, Mnangagwa has tried to cast himself as a forward-looking reformer.

Following independence in 1980, he allegedly was partially responsible for a brutal crackdown on opposition supporters that claimed thousands of lives in Matabeleland. The ZANU-PF veteran was also allegedly involved in deadly violence against the opposition during the 2008 elections.