Kampala (AFP) - Uganda's top court paved the way Thursday for the country's 74-year-old leader Yoweri Museveni to seek a sixth term in office, upholding a ruling to scrap presidential age limits.

The Supreme Court dismissed a challenge by Museveni's opponents, who had appealed against a constitutional court ruling that removed an age cap of 75 for presidential contenders.

"This appeal therefore fails," Chief Justice Bart Katureebe declared in handing down the court's majority 4-3 verdict.

The decision allows Museveni -- who has ruled Uganda since seizing power at the head of a rebel army in 1986 -- to seek re-election in polls due in 2021.

Attorney General Mwesigwa Rukutana declared the verdict "a big win for Uganda".

"We are elated. This is a sign of how democracy has taken root in our country," he told AFP.

But a lawyer for the petitioners, Erias Lukwago, said "it is democracy that suffers".

"It is a disappointment, but in Africa it is a miracle to win (against) a sitting government," he told AFP.

Observers had expected a ruling in Museveni's favour, but the narrow margin came as a surprise.

"The ruling was so close. Museveni will take a lesson from it," said Kassim Male Mabirizi, an activist from the Uganda Law Society and one of the main petitioners.

A bill removing presidential age limits was signed into law in December 2017 after a chaotic passage through parliament that saw MPs engaging in fisticuffs.

- Rule for life -

That decision sparked protests and an outcry from the opposition, which accused the president of seeking to rule for life.

The constitutional court upheld the amendment in a ruling in July last year, but it was challenged by the opposition in Uganda's highest court.

A seven-judge Supreme Court bench began hearing the appeal in January, with opposition lawyers arguing the bill was unconstitutional.

Some of the judges agreed.

"The power to amend is not the same as the power to rewrite the constitution," said Justice Lillian Tibatemwa, one of the three judges who ruled for the opposition.

Story continues

Museveni once said leaders who "overstayed" were the root of Africa's problems.

But in 2005, he scrapped a two-term presidential limit which has allowed him to keep running for office.

While contesting a fifth term in 2016, he said it was not the right time for him to leave as he still had work to do.

In February, the ruling party endorsed Museveni as its candidate for 2021.

- Growing discontent -

He is the only president most Ugandans have known in a country where the median age is less than 16.

But young Ugandans have recently been energised by pop star-turned-MP Bobi Wine, who spearheaded protests against the age-limit amendment and has rapidly become a thorn in the government's side.

Bobi Wine, whose real name is Robert Kyagulanyi, told CNN in an interview in February that he was "seriously considering" running for president in 2021.

Kyagulanyi was charged with treason last August, along with more than 30 opposition politicians, over the alleged stoning of Museveni's convoy after a campaign rally.

During the campaign, Kyagulanyi's driver was shot dead when soldiers from the elite presidential guard raided the hotel in which he was staying.

The singer has accused the security forces of torturing and beating him while in custody and later received medical treatment in the US for the injuries he said he received. The authorities have denied the allegations.