KAMPALA (Reuters) - A Ugandan academic was released on bail on Wednesday after spending more than a month in jail on charges related to posts she made on Facebook criticizing the country’s leader of three decades, Yoweri Museveni.

Ugandan prominent academic Stella Nyanzi stands in the dock at Buganda Road court charged with cybercrimes after she posted profanity-filled denunciations of president Yoweri Museveni on Facebook in Kampala, Uganda April 25, 2017. REUTERS/James Akena

Stella Nyanzi repeatedly accused Museveni and his wife Janet, who is the education minister, of breaking an election promise to offer free sanitary pads to schoolgirls so they do not have to skip classes.

In the posts, made over several months, Nyanzi also accused Museveni - often in colourful language - of nepotism, extravagance, corruption and human rights violations.

Appearing in court in the capital Kampala on Wednesday, she seemed to be walking with difficulty. A prisons spokesman said Nyanzi had been ill but that she had been treated by doctors who determined that the sickness was not severe enough to prevent her court appearance.

Chief magistrate James Eremye Mawanda told the court he had decided to free Nyanzi on bail after ensuring that she would not abscond and that she would not interfere with investigations.

Nyanzi was ordered to deposit her passport in court’s custody and she and five supporters had to offer 10 million Ugandan shillings ($2,755) of surety apiece.

Museveni, 72, has ruled the east African country for 31 years. Rights groups and opposition activists say he has grown increasingly authoritarian and intolerant of dissent.

Jailing of opposition activists and leaders is routine and security forces often refuse permission for anti-government protests or break them up with teargas and beatings.

Museveni concedes there are corrupt officials in his government but says he is working hard to eradicate the vice. He denies his government has trampled human rights and says members of his family in government are recruited on their own merit.

Nyanzi is a lecturer and research fellow at a public university. The blunt tone of her social media posts, often mingled with sexual obscenities, has earned her a large following online and in local media.

She was detained on April 7 and charged four days later with electronic communications offences relating to her Facebook posts. She was accused of hurling an obscenity at Museveni by calling him a “pair of buttocks” and posting other messages that had violated his peace and right of privacy.

Her lawyer, Isaack Ssemakadde, told Reuters Nyanzi would next go to court on May 25 and proceedings to determine whether she should undergo a psychiatric test would commence.

Prosecutors have petitioned the court to order a mental examination to determine her sanity but her lawyers have objected, saying the examination was a trick to have her declared insane and confined as a mental patient.