Chief Justice Luke Malaba said on Friday that the Movement for Democratic Change (MDC) alliance, led by 40-year-old Nelson Chamisa, had failed to prove fraud accusations during the vote.
"The application is dismissed with cause ... Emmerson Dambudzo Mnangagwa is duly declared the winner of the presidential elections held on the 30th of July 2018," Malaba said in his ruling.
Mnangagwa, 75, said he was "not surprised by the court's decision" and called for unity and peace.
"Nelson Chamisa, my door is open and my arms are outstretched, we are one nation, and we must put our nation first. Let us all now put our differences behind us. It is time to move forward together," Mnangagwa wrote on Twitter shortly after the court announced its ruling.
The MDC had filed a legal challenge, citing a catalogue of alleged discrepancies, including incorrect counting and fake polling stations, as well as instances at voting centres where there were more ballots cast than registered voters.
"There has been a massive doctoring of evidence," Thabani Mpofu, a lawyer representing the MDC, told the top court when it started sitting on Wednesday.
Mnangagwa, of the ruling ZANU-PF party, won the election with 50.8 percent of the vote, just enough to pass the 50 percent threshold needed to avoid a runoff against Chamisa, who finished second with 44.3 percent.
European Union observers said that the ZANU-PF candidate had benefitted from an "un-level playing field" and some voter intimidation, though international monitors largely praised the conduct of the election.
The legal challenge delayed Mnangagwa's planned inauguration for August 12. According to the Constitution, the inauguration should take place within 48 hours of the court's ruling.
Mnangagwa took over after a military intervention in November 2017 resulted in the resignation of 93-year-old President Robert Mugabe, who ruled Zimbabwe for 37 years.
Mnangagwa, who has promised to revive the country's ruined economy, had vowed that the vote would be free and fair amid hopes that it would open up a stream of foreign investment and aid.
Wilf Mbanga, political commentator and editor of The Zimbabwean, said the court challenge would put in question ZANU-PF's election victory.
"Global acceptance will be difficult. Investors may be difficult to attract," Mbanga told Al Jazeera.
Campaigning was more open than previous votes, but the election was marred by violence and a crackdown on opposition activists.
On August 1, clashes broke out in central Harare between security forces and opposition supporters. Six protesters died after soldiers opened fire, in a response that the opposition alliance called "disproportionate and unjustified".
"Praetorian politics will continue to define the political landscape and this is unsettling not only because the presence of the military on the foreground of our politics is likely to result in repression and plunder as evidenced by the killing of unarmed civilians," Michael Choto, a political analyst, told Al Jazeera.
He called for the disbanding of "the patronage and corruption network that has characterised our country's politics for the last 38 years".
In the parliamentary elections, also held on July 30, ZANU-PF secured a clear majority by winning 145 seats in the 210-strong parliament. The MDC came second with 63.
The ruling party, which has been in power since independence in 1980, has ruled out any form of political alliance with the opposition.
But some analysts said a coalition would ease political tensions in the country.
"This would be first prize and would solve a lot of problems but is highly unlikely given the extreme polarisation which has actually been worsened by the court case and the post-election killings," Mbanga said.
"The winner-takes-all attitude will be disastrous but I fear that is what will happen. Although I hope Mnangagwa is pragmatic enough to see that would be counterproductive," he added.
Choto said the MDC, which has historically been ZANU-PF's biggest challenger, "should regroup, re-evaluate ... and reshape" its strategy with a focus on ensuring victory in the 2023 elections.
"Nelson Chamisa has time on his hands," he said.
"He has the changing demography of Zimbabwe on his side, he should not allow himself and the alliance to be swallowed, to legitimise a military government that has come to power not through the ballot but by the barrel of a gun."