Nigeria's Appeal Court has rejected challenges to Bola Tinubu's narrow victory in February's presidential election.
After an almost 10-hour verdict, judges said the petitions by his two main challengers were without merit.
Both Atiku Abubakar of the Peoples Democratic Party and Peter Obi of the Labour Party had alleged widespread fraud.
Despite the election challenge, Mr Tinubu was sworn into office on 29 May.
The election was the most fiercely contested since the end of military rule in 1999, with three strong candidates for the first time. Mr Tinubu won with 37% of votes cast, against 29% for Mr Abubakar and 25% for Mr Obi.
A presidential spokesman said President Tinubu welcomed the judgment "with an intense sense of solemn responsibility and preparedness to serve all Nigerians."
"[It] reflects the continuing maturation of Nigeria's legal system, and the advancement of Africa's largest democracy at a time when our democratic system of government is under test in other parts of the continent," Ajuri Ngelale said in a statement.
The country was tense before Wednesday's ruling, with increased security in the capital, Abuja.
Despite warnings from authorities against demonstrations, various political groups gathered outside the courthouse, singing and dancing.
The ruling on the same day he marked 100 days in office will be a huge relief to President Tinubu who will now keep an eye on the Supreme Court where his opponents are likely to appeal against this judgement.
The Labour Party has rejected the ruling.
"We reject the outcome of the judgment in its entirety because justice was not served," party spokesman Obiora Ifoh said in a statement quoted by local media.
But the unanimous verdict by the judges at the Appeal Court will fill Mr Tinubu with confidence. This was already on display as he was not even in the country for Wednesday's ruling, travelling to India for the G20 summit.
Lead justice Haruna Tsammani, who read the verdict, said "the petitioners failed to prove allegations of corrupt practices and over-voting".
Justice Tsammani also said that:
the petitioners failed to specify the polling units where they alleged that rigging took place
the petitioners failed to provide any credible evidence to prove their allegations of suppression of votes in their strongholds
the electoral commission was not bound to transmit results electronically
failure to upload the photographic copies of polling unit results in real time did not invalidate the election.