Nicaragua's President, Daniel Ortega (L), shaking hands with Russian Defense Minister, general Sergey Shoigu (R), during a meeting at the Sandinista Front Secretary, Managua, Nicaragua, on 12 February 2015. (Cesar Pérez / Nicaragua Presidency Handout/EPA)

This week marks the 25th anniversary of the free election in which the Nicaraguan people ousted the Marxist Sandinistas from power after 12 long years of revolution, war and poverty.

It was part of a global democratic revolution, the dramatic high point of which came with the fall of the Berlin Wall in November 1989.

Today, however, Nicaragua is back under the rule of the Sandinistas — or, more precisely, the rule of Sandinista President Daniel Ortega and his family. Democracy there “continues to be weakened by the authoritarian tendencies of the president, and efforts to subvert the constitution for his political benefit,” in the words of the Economist’s Intelligence Unit. Translation: The Ortegas are building a dynastic pseudo-democracy eerily like the Somoza regime the Sandinistas overthrew in 1979.

In short, if little Nicaragua epitomized the democratic revolutionary spirit of 1989, now it epitomizes a resurgence of dictatorship, illiberalism and anti-Americanism. Freedom House recently reported “a disturbing decline in global freedom in 2014,” the ninth straight year in which the organization has documented democratic back-sliding. The worst case, perhaps, is in this hemisphere: formerly democratic Venezuela, which manages to be both brutally repressive and wildly chaotic. But the trend is manifest from Beijing to Ankara to Budapest.

What went wrong? The United States, which spearheaded the democratic wave as part of its Cold War endgame, moved on to the war against terrorism after Sept. 11, 2001, a long and necessary, but draining, struggle that became Washington’s rationale for making common cause with various dictatorships.

Attempts to occupy and democratize Iraq and Afghanistan went sour, sowing permanent doubts, both in America and abroad, about democracy’s universal applicability — and about the United States’ democratic credentials, given its own compromises, and its own controversial measures against terrorism such as the prison at Guantanamo. The “Great Recession” and partisan gridlock damaged the democratic capitalist brand.

Yet all of that would not have generated an anti-democratic wave unless there were forces determined to make such a wave happen. Amid the joy and — let’s admit it — triumphalism of 1989, we forgot that revolutions have a way of spawning counterrevolutions.

Indeed, we failed to notice that the seeds of that counterrevolution were being sown even then: most notably in the crackdown at Beijing’s Tiananmen Square in June 1989 but also in places such as Havana, where the Castro regime purged and executed reformist military and intelligence officers after a Stalinist show trial.

And that is what we are witnessing now: the deliberate erosion, ma­nipu­la­tion or outright destruction of liberal democracy, if not always by the very people who lost out a quarter-century ago, as in Nicaragua, then by their political heirs.

The counterrevolution’s hallmarks are an unapologetic ideological attack on democratic capitalism; the revival of “traditional” moral values allegedly threatened by the decadent, conniving West; assertiveness about national interests, real and invented; and, perhaps most important, flexibility about methods. Illiberal states, parties and politicians have learned to exploit democratic institutions — elections, media and free markets — in order to undermine them.

The counterrevolution’s headquarters are in Russia and China, but its influence goes far beyond that and spreads through opportunistically shifting military, political and commercial relationships. These connections sustain regimes — North Korea, Cuba, Syria, Belarus — that were once left for dead but have survived and even forced Washington to deal with them.

To be sure, the most disappointing defeat for liberal governance and democracy has been the Arab Spring, which degenerated into sectarian warfare and authoritarianism almost everywhere except for Tunisia. Bitter as this setback has been, though, it’s not a net loss for global democracy, since the Arab Middle East knew so little liberal governance prior to the upheaval.

Of even greater concern is the prospect of democratic decay, or even rollback, in Europe, as that aging continent comes under pressure from four directions: dysfunctional politics, Russian aggression, economic stagnation and Islamist terrorism.

Europeans and Americans can and should reflect candidly on the moral and political sins we have committed in history, including recent history. And we’ve been doing a lot of that lately, from President Obama on down.

Amid the self-criticism, though, we should spare a few moments to recall the Spirit of ’89, and to reflect on the crucial part American power and policy played in bringing about that magnificent surge of freedom. At its best, the democratic revolution’s animating attitude was not hubris but confidence; absolute confidence in liberal democracy’s relative superiority, you might say.

Today, all the confidence seems to be on the counterrevolution’s side. That must change, lest the United States find itself heading a dwindling, and weakening, band of like-minded nations — and lest history record that the fateful events of 1989 actually occurred not in Berlin but in Beijing.

Read more from Charles Lane’s archive, follow him on Twitter or subscribe to his updates on Facebook.