MYRIAD FORCES pull girls from school across poor swaths of the globe. One is menstruation, long a taboo subject that causes fear and shame, and as a practical matter forces girls to miss school for lack of basics such as sanitary pads or toilets. Stella Nyanzi, a firebrand activist in Uganda, spoke up about this, criticizing the wife of Uganda’s president, and is now in jail because of it.

Ms. Nyanzi, a mother of three and an academic, is a controversial figure who champions LGBT rights in a land where homosexual acts are outlawed. She often shocks people to get attention, such as the time she undressed on television, and frequently uses vulgar language while lighting up social media to prod the powerful. Her latest campaign involved a broken promise by Uganda’s autocratic President Yoweri Museveni, who has held power for three decades and was reelected in February 2016 amid reports of voting irregularities, ballot-box stuffing and intimidation of opposition candidates.

In the campaign, the president and his wife Janet, who is also education minister, promised to fund free sanitary pads for girls in Uganda. But earlier this year, Ms. Museveni told parliament that the promise wouldn’t materialize because there wasn’t enough money. This appears to have infuriated Ms. Nyanzi, who supported the opposition candidate Kizza Besigye, and she began to attack the president and his wife. She also started a campaign to raise the money for the promised sanitary pads.

Ms. Nyanzi’s anger appeared in her Facebook posts. On January 27, she denounced Mr. Museveni as a “pair of buttocks” and said that Ugandans should be “shocked that we allowed these buttocks to continue leading our country.” On Feb. 15, she declared she would not call the president’s wife “Mama Janet” as others do, asking: “What sort of mother allows her daughters to keep away from school because they are too poor to afford padding materials that would adequately protect them from the shame and ridicule that comes by staining their uniforms with menstrual blood?”

Mr. Museveni has never hesitated to muzzle his critics, and he swung into action against Ms. Nyanzi. First her home was raided and threats issued; then Ms. Nyanzi was arrested. Her crime, according to the charge sheet, was “cyber harassment” for the first posting on Facebook, where she “willfully and repeatedly used electronic communication to . . . disturb the peace, quiet, or right of privacy of his excellency the president of Uganda Yoweri Kaguta Museveni with no purpose of legitimate communication.” She is now being held in a maximum-security prison in Kampala.

Mr. Museveni has enjoyed close ties with the United States, and truckloads of aid. This should not give him the sense that he can ignore criticism of his actions. By putting Ms. Nyanzi in prison he is not only violating her right to speak up, but also locking up the hopes of girls in Uganda for a simple measure to keep them in school.