President Emmerson Mnangagwa has won Zimbabwe's presidential election, according to the electoral commission.
With all 10 provinces declared, Mr Mnangagwa won 50.8% of votes, compared to 44.3% for opposition leader Nelson Chamisa.
Police removed opposition officials from the electoral commission stage when they rejected the results.
The chairman of Mr Chamisa's MDC Alliance said the count could not be verified.
By narrowly winning more than 50% of the vote, Mr Mnangagwa avoids a run-off election against Mr Chamisa.
The president said on Twitter he was "humbled", and called the result "a new beginning".
Mr Mnangagwa, from the governing Zanu-PF party, took over as president last November from long-serving leader Robert Mugabe.
Allow Twitter content?
Mr Chamisa has insisted he is the winner of the presidential poll, telling reporters earlier on Thursday that Zanu-PF was "trying to bastardise the result", something "we will not allow".
But the Zimbabwe Electoral Commission (Zec) said there was "absolutely no skulduggery".
Six people died after opposition protests in Harare on Wednesday over alleged vote-rigging.
The elections were the first since Mr Mugabe, 94, was ousted and were intended to set Zimbabwe on a new path following years of repressive rule.
Harare was reported to be quiet on Thursday, as troops patrolled the city centre ordering people to "behave".
Mr Mnangagwa said the government was in talks with Mr Chamisa to defuse the crisis. He proposed an independent investigation to bring those who were behind the violence to justice.
"This land is home to all of us and we will sink or swim together," Mr Mnangagwa said in a series of tweets.
What happened after the vote?
The day after the election, the MDC Alliance said Mr Chamisa had won the presidential vote, pre-empting an official announcement and prompting its supporters to celebrate in some areas of Harare.
The following day, when Zec announced that Zanu-PF had won the parliamentary vote by a landslide, tensions rose.
Opposition supporters were also angered by the delay in announcing the presidential results.
Home Affairs Minister Obert Mpofu said the government would not tolerate such protests.
The opposition "are testing our resolve, and I think they are making a big mistake", he said.
A spokesman for Mr Chamisa condemned the deployment of soldiers and the subsequent loss of life.
"Soldiers are trained to kill during war. Are civilians enemies of the state?" he asked.
"There is no explanation whatsoever for the brutality that we saw."
More on post-Mugabe Zimbabwe:
What are the full results?
Zec announced the results from the 10th and final province, Mashonaland West, late on Thursday after days of waiting.
The European Union and Commonwealth missions earlier criticised the delay in announcing the presidential results.
This is the first time in 16 years that the government has allowed EU, Commonwealth and US election monitors into the country.
Earlier in the week, Zec announced the parliamentary results, giving Zanu-PF 144 seats, the MDC Alliance, which is made up of seven parties, 64 seats, and one seat to the National Patriotic Front, formed by Mugabe loyalists after he was ousted.
Although Zanu-PF won by a landslide, its majority has shrunk since the 2013 election, when it obtained 160 seats and the MDC, then led by the late Morgan Tsvangirai, 49.
More than five million people were registered to vote in Monday's poll. Turnout was 70%.