Thirty-eight years ago — August 14, 1980 — Polish workers at the Gdansk shipyard went on strike to press for not only pay raises but also the right to belong to an independent union that would be free of communist control. So began the Solidarity labor movement that inspired opposition to communist rule in Poland and across Central Europe, ultimately leading to the collapse of the communist bloc.

Polish resistance proved contagious, clearing the way for the fall of the Berlin Wall in 1989 and the implosion of the Soviet Union a few years later.

Poland did not look back. It adopted capitalism and its economy took off. It joined NATO in 1999 and the European Union in 2004. Along with its Central European neighbors, Poland embedded itself in Western markets, practices and institutions.

As the 21st century opened, democracy appeared to have finally triumphed over autocracy. Out of the courageous strike in Gdansk emerged a stunning and remarkable success story.

Not so fast.  History has gone into reverse. Unsettled by globalization and immigration, Poland is abandoning its hard-won embrace of Western values. Its populist government is stacking the courts, seeking to control the news media, purging the civil service, and intimidating civil society organizations.

Hungary has already gone down that path. Britain is exiting the European Union, while recent elections in Italy have brought to power a coalition that is turning away refugees and stoking a racist brand of nationalism. Across much of Europe, populists and xenophobes are on the march.

The situation in the United States is hardly better. A racially tinged nationalism is eroding pluralism and tolerance. The White House propagates false claims as it launches daily attacks against the mainstream media. Tensions are building across racial, ethnic, geographic and class lines.

Surely, the West’s own success is contributing to democracy’s discontents.  Technological advance and open trade have spawned economic duress across the United States and Europe. Uncontrolled flows of people across national borders have understandably provoked a backlash against immigration.  Social media has made democratic institutions particularly vulnerable to manipulation. And transnational threats such as terrorism and climate change — although soluble only through collective action — have induced electorates to turn inward and raise protective barriers.

But the answer to these challenges is not to abandon Western values and retreat from the world as we look for scapegoats. It is to adapt to inevitable social and economic change by ensuring that the benefits of globalization are shared equitably across class, to arrive at immigration policies that are both firm and fair, and to work with, not against, other nations to solve collective problems.

Recalling Poland’s successful defeat of communist rule helps put our current predicament in perspective. I first visited Poland in 1983, after the communist regime had imposed martial law to snuff out Solidarity. The movement’s leaders had gone underground, but they insisted on meeting me in hotel lobbies and other public venues in order to demonstrate that they would not be cowed by the regime.  One of Solidarity’s leaders told me that he and his colleagues were living in “internal exile.”  They resided in Poland physically, but not politically.

In effect, civil society had separated itself from the state. The regime had lost any pretense of legitimacy — precisely why it was only a matter of time before it would collapse.

The triumph of Solidarity was a triumph of human will. Facts won out over fiction.  Respect for human dignity defeated the cynicism of the authoritarian state. The resistance to sham leadership became so widespread that communist leaders, including those in the Kremlin, could not repress the will of the people.

This uplifting story of Poland’s transition from Soviet satellite to courageous democracy makes the current reversal of fortune all the more stunning.  With the collapse of the Soviet Union, democracy looked unstoppable. But now the West is stumbling badly; democratic institutions have become dysfunctional, social cohesion has been replaced by bitter division, and openness, pluralism, and free trade have given way to fear of the other, intolerance, and protectionism.

The West has arrived at a moment of reckoning. The Atlantic democracies can pull themselves up by the bootstraps and reclaim the values and practices that made them great. Or they can accept defeat and retreat.

Americans and Europeans should look to the Gdansk strike of August 14, 1980, for guidance. Defeating communism took political fortitude, tenacious resistance and an unwavering commitment to human dignity.

Defeating today’s rising illiberalism will require nothing less.