The ruling on Thursday that the re-election of Yoweri Museveni was valid, despite irregularities, was denounced by the president's main rival, Kizza Besigye, who called for protests against the "glaringly invalid" poll.
Besigye, Museveni's former doctor, alleged that widespread fraud had caused his defeat in the east African nation's vote on February 23.
Chief Justice Benjamin Odoki, said on Thursday: "By a majority of four to three, it was not proved to the satisfaction of the court that this non-compliance [of electoral laws] affected the result of the presidential election in a substantial manner."
He said the judges noted irregularities in vote counting, in the deletion of thousands of names from the voting register, and said bribery and violence had compromised a free and fair ballot "in some areas of the country".
But the judges said the incidents did not merit a rerun of the polls, which Besigye had wanted, or even a recount.
The judges raised what they called "grave concerns". These included the involvement of security forces in the voting process and the apparently biased conduct of some election officials.
Odoki said: "We are of the opinion that all the institutions and persons involved should urgently address these concerns to improve electoral democracy in the country."
"We shall vigorously mobilise all Ugandans to channel the popular discontent towards actions that will weaken and dislodge the dictatorship through all legitimate means available"
Besigye said it was unfortunate that the court had not cancelled an election that was "glaringly invalid", and called on his supporters to hold demonstrations.
He said: "Uganda is right back to square one after 25 years. ... We shall not associate ourselves with or respect this decision.
"We shall vigorously mobilise all Ugandans to channel the popular discontent towards actions that will weaken and dislodge the dictatorship through all legitimate means available."
Museveni, 62, a former guerrilla leader who took power in 1986 after a bush war, won the election with 59% of the vote versus 37% for Besigye.