Adam Bodnar, Poland’s new justice minister, recently explained to me the immense challenge of rebuilding liberal democracy in his country after an eight-year slide toward authoritarianism. Imagine, he said, that Donald Trump had won the last election and been in power for two terms instead of one. “What would be the damage?” he asked.

After only four years of Trump, President Biden inherited a furiously divided nation, its courts seeded with right-wing apparatchiks and the nature of reality itself in deep dispute. But as even MAGA die-hards will acknowledge, Trump often failed to bend the state to his will, which is why his allies have a plan to do things differently next time, purging civil servants and replacing them with loyalists. Poland is a country that has just gone through something like what Trumpists hope to impose on us in a second term. Its institutions have been hollowed out. Many experienced technocrats and neutral judges have been replaced by lackeys and ideologues.

And now it’s trying to repair itself, which is why I flew there last month. In a world where liberal values seem to be in retreat almost everywhere, Poland is a rare bright spot, a place where voters — especially women and young people — rebelled against a punishing religious nationalism to demand the restoration of their rights. The parallels to the backlash against the American Supreme Court’s decision in Dobbs v. Jackson Women’s Health Organization, which overturned Roe v. Wade, were impossible to miss. But while being in Warsaw was inspiring, it was also sobering, because it quickly became clear to me just how complicated it is to fix a modern democracy that’s been systematically undermined, a lesson we might someday have to learn in America. Poland, said the Harvard professor Daniel Ziblatt, a coauthor of the 2018 best seller “How Democracies Die,” is “a good news story about how electoral authoritarianism can be dislodged, and then the limits of what happens next.”

When I met Bodnar, a widely admired legal scholar in his late 40s, Poland’s new administration, led by the centrist, pro-European Prime Minister Donald Tusk, had been in office for just over a month. The previous government, the deeply Catholic, reactionary Law and Justice Party, had ruled since 2015, coming to power as part of the same populist wave that brought the world Brexit and Trump. In the October election, Law and Justice used various maneuvers to tilt the electoral playing field in its favor; a month before it took place, the German Marshall Fund declared that the upcoming Polish vote “will not be fair.” But a stunning level of voter turnout — over 74 percent — overcame the ruling party’s advantages. Young people flooded the polls; according to exit surveys, those under 30 voted at higher rates than those 60 and older. It was a victory so momentous that liberal Poles kept comparing it to 1989, when the democratic Solidarity movement triumphed over communism. Law and Justice delayed the transition to a new government until December, but it could not prevent it.

For Poland’s democrats, the election was “our last attempt to push back against us going to the Budapest direction,” said Aleksandra Wisniewska, a newly elected member of parliament, referring to the more entrenched autocracy in Hungary, which Law and Justice openly emulated. Wisniewska herself represents a new spirit in Polish politics; a former humanitarian aid worker and the daughter of an immigrant from Thailand, she made issues like women’s rights and democracy central to her campaign. Now, at 29, she’s the youngest woman in Poland’s Sejm, parliament’s lower house, and the only person of color.