KAMPALA, Uganda — Uganda’s Supreme Court has rejected a challenge to the presidential election held in February, issuing a ruling on Thursday that secured President Yoweri Museveni a mandate for another five-year term. He has been in office since 1986.

The vote last month, seen as a pivotal moment in Uganda’s democracy as the last time Mr. Museveni will be legally allowed to appear on a presidential ballot, was marred with irregularities and widespread criticism.

The legal challenge by the third-place finisher, Amama Mbabazi, argued that Mr. Museveni was not validly elected and that Uganda’s electoral commission had disseminated false results, among other allegations. It requested a recount in more than 40 districts.

Under Ugandan law, which bars presidential candidates over the age of 75, it was the last election in which Mr. Museveni, 71, will be allowed to run.