LGBT refugees living in Kenya stand behind a rainbow flag as they protest against their treatment by authorities, outside an office of the U.N. refugee agency in Nairobi on May 17. (Ben Curtis/AP)

The past few weeks have been a wake-up call for pro-democracy activists across Africa — a painful reminder that three decades after the fall of the Berlin Wall precipitated a tidal wave of democratization around the world, the gains made remain precarious. The massacre of protesters by the army on the streets of Sudan’s capital, Khartoum, last week, and the stalemate in Algeria are clear signs that nothing can be taken for granted in the second wave of citizen uprisings.

And it is not just in the regimes of North Africa, which for the most part missed the democracy boat in the 1990s, where concerns are rising. Further south, in countries such as Zimbabwe, which itself was a latecomer to democracy, having just rid itself of Robert Mugabe’s 37-year dictatorship in 2017, Mugabe’s successors have turned out to be the very people who enabled his tyranny. As seems to be happening in the other two nations, the revolution has come full circle.

Even in those countries that did benefit from the first wave of democratic change, the signs are not at all rosy. The hard-won democratic and human rights appear to be increasingly in retreat in countries such as Tanzania, where a populist demagogue is jailing journalists and bloggers and shutting down avenues of dissent, and more recently in my own country, Kenya.

In the region, there is perhaps no other country where resistance to the predation of the state has been sustained for so long. From confronting the colonial regime in a series of uprisings, to employing street protest and mass action to recover rights from the Daniel arap Moi dictatorship, to successfully resisting Mwai Kibaki’s attempt in 2005 to impose a bastardized constitution and, less successfully, steal an election two years later, to confronting the current regime of President Uhuru Kenyatta when it did the same, Kenyans have a long history of fighting for fundamental freedoms.

Still, even here, the freedoms that many have fought and died to preserve are again imperiled by those who wish to see a less open and tolerant society. The most recent attack has come from an unlikely quarter.

At the beginning of September 2017, the country’s judiciary was basking in the spotlight of global adulation, after it became only the fourth in history and the first in Africa to annul a presidential election. The luster has been fading ever since, partly as a result of the attentions of a revenge-seeking executive, and partly as a result of corruption within its own ranks. But now, a series of judgments it has handed down has raised the specter of the courts undoing the guarantees of freedom and accountability contained in the Constitution enacted in 2010 after almost a quarter century of struggle.

Perhaps the most consequential and outrageous of these is the decision to uphold colonial-era laws that criminalize certain sexual acts — specifically targeting the LGBT community. The laws forbid sexual acts “against the order of nature” and acts of “gross indecency,” specifically those committed between males, and impose a prison term of up to 14 years.

Even to a legal layman, the High Court’s judgment is a study in contradictions and mental gymnastics. The judges argue that discrimination, though outlawed by the Constitution, can still be legal; that the laws, which they claim are not just about sex but also about ensuring same-sex couples cannot live together in marital relationships (despite the fact that customary marriages between women have been recognized as legal), somehow do not target the LGBT community; that allowing gay men to have sex is the same thing as allowing them to get married; and that same-sex marriage would offend the Constitution, even though it contains no such prohibition.

Though the parties who challenged the constitutionality of the laws have vowed to fight on, the decision is part of a series that has led some to question the commitment of the courts to uphold the constitution. The courts have also recently ordered anti-corruption crusader and former permanent secretary for governance and ethics, John Githongo, to pay approximately $270,000 plus legal costs with interest to former cabinet minister Chris Murungaru for naming him in an official report. And in another outrageous judgment, the Court of Appeal said the government did not have to disclose how much public money it had spent on illegal advertisements in support of Kenyatta’s 2017 reelection campaign.

While today most eyes are focused on the reversals happening in the countries that have only recently attempted to cast off the shackles of dictatorships, it is important that the world is not blind to the betrayals occurring in countries where the fight was once assumed to have been won. As German Chancellor Angela Merkel warned graduating students in her address at Harvard, nothing can be taken for granted.

Read more:

The Post’s View: A chance for democracy in Sudan is being snatched away. The world must act.

The Post’s View: Sudan’s revolution could end up like Tiananmen — or even more tragic

Patrick Gathara: What the unspeakable tragedy of Caroline Mwatha reveals about Kenya

Melyssa Haffaf: Algerian women have waited 57 years for equality. Now it’s time for action.

Patrick Gathara: Kenyans suspend skepticism amid Nairobi attack. But we should know better.