By Dalibor Rohac

Dalibor Rohac is a research fellow at the American Enterprise Institute.

To any fair-minded observer, President Trump’s authoritarian instincts, Twitter outbursts and divisive rhetoric should be greatly concerning. Americans might take comfort in the fact that the United States is not the first country to elect and live under such a leader. I would know.

Two and a half years after the fall of communism in 1989, the ruthless and charismatic Vladimir Meciar was elected as prime minister in my home country of Slovakia after a brief previous stint in the office. His larger-than-life personality and bombastic rhetoric filled much of the media space, often with lies and conspiracies. His opponents, many of them former dissidents from the old era, lacked the rhetorical skills, charisma and political acumen to compete.

Notoriously unstable, Meciar lashed out against critics when under pressure. He rejected experts who, he argued, didn’t understand Slovakia’s exceptionalism. Instead of opening the country to international businesses, he let his cronies get spectacularly rich by seizing publicly owned assets. At regular intervals, Meciar got into unprovoked fights with leaders of neighboring countries and indulged in crass jokes about their sex lives. More seriously, he was widely suspected of using the politicized secret service against his political opponents. No wonder that then-U.S. Secretary of State Madeleine Albright once called the country a “black hole in the heart of Europe.”

But my country’s story had a happy ending. After the 1998 election, Meciar’s Movement for a Democratic Slovakia was unable to secure a parliamentary majority and lost power to a broad coalition of center-right and center-left parties.

Three factors accounted for Meciar’s demise. First, his base was slowly eroding, as his supporters were often drawn from older segments of the population. In 1994 his party received more than 1 million votes in a country of more than 5 million people. Four years later, it was down to about 900,000. Meanwhile, turnout went up by almost 10 percentage points, from 76 percent to 84 percent, as larger numbers of younger and urban voters became alarmed by the country’s drift away from the West. Even though his party came first in the 1998 election, Meciar was unable to form a government coalition that would command a parliamentary majority. Although his party lingered in parliament until 2010, Meciar has never again held a government office.

Having first secured control of public broadcasting and other media outlets, Meciar was extremely effective in keeping his core group of supporters energized, but not much else. For other voters his frequent outbursts became increasingly off-putting. Even apathetic segments of the electorate were alarmed when, under Meciar’s watch, the secret service came under suspicion for kidnapping and nonfatally electrocuting the son of the Slovak president, Michal Kovac, who was Meciar’s political nemesis. The key witness in the case was later killed in a car bombing. These crimes were later amnestied by Meciar during his brief stint as acting president in 1998.

Second, Meciar’s demise was precipitated by the emergence of an effective opposition that coalesced around the questions that mattered the most: rule of law and Slovakia’s place among European democracies. Like Trump, Meciar first rose to power by sidelining rivals in his own party and staging a flurry of media stunts that left his opponents paralyzed and divided. At the time, Slovakia had a vast array of small, mostly center-right, parties, which differed in the emphasis they placed on economic reforms, family values and environmental protection. Meciar’s power was the greatest when the opposition was divided and mired in debates over irrelevant minutiae.

The consolidation of opposition forces was not easy and many egos were hurt in the process. The credit for its success goes to Mikulas Dzurinda, an astute political operator who bound five small parties together to form the Slovak Democratic Coalition, which later became the cornerstone of the post-Meciar reformist government. America’s two-party system makes direct comparisons complicated, of course. But if Trumpism is to be defeated, it will require politicians on the center-right and the center-left to get organized around questions that matter — most importantly, the defense of the liberal democratic character of the U.S. government.

Third, Meciar’s political decline had a strong international dimension. Meciar’s brutish manners alienated Slovakia’s neighbors, as well as Brussels and Washington. In defending himself, he tried to sell his voters a grotesque idea of an international conspiracy directed against Slovakia. His domestic critics, too, were smeared as paid agents of anti-Slovak forces abroad. That message resonated with Meciar’s core supporters, but more and more Slovaks saw that their country’s growing isolation was purely of their own government’s making.

Washington and Brussels stood firmly against Meciar’s transgressions, especially regarding rule of law and his treatment of its Hungarian minority. As a result, Slovakia was dropped from the first wave of NATO enlargement after the Soviet Union dissolved and found itself at risk of missing out on European Union membership — in embarrassing contrast to its neighbors Poland, Hungary and the Czech Republic.

Paradoxically, the fallout from the Meciar years created a sense of urgency in the realms of economic reform and foreign relations. When Dzurinda became prime minister in October 1998, the country faced a currency crisis and much of the banking sector was insolvent. Dzurinda’s two successive governments turned things around. Slovakia joined NATO in 2004 and caught up with its neighbors in the E.U. accession process. Due to bold reforms, the country’s high-performing economy earned it the nickname of the “Tatra Tiger.” Slovakia was also the first country in East Central Europe to join the euro zone, in 2009.

Even so, Meciar’s attack on the nascent rule of law in the 1990s continues to haunt the country. Corruption, which reached gigantic proportions under Meciar, has never gone away. Meciar took pride in his crony privatization, which created what he called a “Slovak capital-owning class,” loyal to him. Today, politically connected businesses are enriched through overpriced procurement tenders or tax fraud.

Meciar’s infamous amnesties for what were widely believed to be acts of political violence have left a traumatic legacy too, creating an ominous sense of impunity for those in power. His years also entrenched a generation of communist-era judges, many of them in cahoots with the political class. According to a recent survey, only a third of Slovaks trust the court system.

The resulting sense of nihilism about the trustworthiness of Slovakia’s government has contributed to a worrying rise in political extremism and growing support for anti-establishment, conspiracy-touting movements, all the way to outright neo-Nazis. It all goes to show that, in Slovakia as in the United States, nurturing the institutions of liberal democracy requires much more work than simply keeping aspiring authoritarians at bay. It requires ensuring that liberal democratic governments are seen as legitimate and effective at delivering key public goods, including justice and security.

Overall, however, Slovakia’s story is an optimistic one, as it shows that creeping authoritarianism can be defeated — even in a vulnerable society.

In the early 1990s, Slovakia had just woken up from 40 years of communist rule: Its democratic institutions, rule of law and civil society were weak.

Yet it succeeded in fighting off Meciar’s abuses of power.

Surely Americans will not let their traditions of democracy and limited government be destroyed by a hyperactive and unstable reality TV host — at least not without a fight.