KAMPALA, Uganda (AP) — A Ugandan academic detained for calling the president "a pair of buttocks" was freed on bail Wednesday after spending over a month in jail.

Stella Nyanzi, a research fellow at Makerere University, appeared frail and had to be assisted by prison warders.

Nyanzi faces charges of offensive communication and cyber harassment over her Facebook posts targeting President Yoweri Museveni and his wife, Janet, Uganda's education minister. The posts criticized the president for not providing sanitary napkins for schoolgirls, a campaign promise that the first lady later said could not be fulfilled because of lack of money.

Nyanzi called the first lady "foolish" and out of touch with ordinary Ugandans. Many families cannot afford sanitary napkins, one reason often cited for girls dropping out of school.

The case is widely followed in this East African country where few people dare to publicly criticize the first family in bold terms.

Amnesty International and several Ugandan rights groups have called for Nyanzi's unconditional release.

"The government's attempt to prosecute her for speaking out for the rights of Uganda's women and girls is an affront to freedom of expression," Amnesty's Sarah Jackson said after Nyanzi was released. "The continuation of this farcical case blatantly violates Uganda's constitution."

Museveni has ruled Uganda since 1986 and is increasingly accused of aiming to rule for life. His opponents are frequently jailed or beaten by police.

A prosecutor has argued it is possible Nyanzi has a mental illness and should be subjected to a psychiatric exam. Her lawyers have opposed an exam, saying it is intended to strip her of her dignity.

The U.S. ambassador to Uganda, Deborah Malac, recently called Nyanzi's case "the latest of serious and growing constraints" faced by the media in Uganda. The government called her comments "condescending."