(OPINION) The Washington Post – THE HISTORY of North American attitudes toward Latin America is in part a story of serial infatuations with various revolutions and regimes. The left fell in love with Fidel Castro’s Cuba and Sandinista Nicaragua; many on the right hailed the supposed free-market magic of Chile under Gen. Augusto Pinochet.

Through it all, one country whose political and social systems actually deserved to be held up as a model never quite captured the “yanqui” imagination: Costa Rica has been a peaceful multiparty democracy since 1949, with high levels of literacy, near-universal access to health care and, blessedly, no standing army. Maybe Americans found this oasis of order and progress unexciting compared with its more turbulent Central American neighbors.

In any case, we are happy to report that, in a world where populism of all stripes is on the rise, and liberal democracy seems to be on the defensive, Costa Rica continues to embrace tolerance and civility. On Sunday, voters turned out in larger-than-usual numbers to elect Carlos Alvarado Quesada as president — and to reject the candidacy of right-wing populist Fabricio Alvarado Muñoz (no relation), which was based almost exclusively on opposition to same-sex marriage. Mr. Alvarado Muñoz, sounding a note of Trumpian neo-nationalism, not only promised to ignore a January ruling in favor of marriage equality by the San Jose-based Inter-American Court of Human Rights but also hinted at pulling the country out of the Organization of American States. Contrary to polls that had shown a dead heat going into election day, 60 percent of the electorate rallied to Mr. Alvarado Quesada and his message of inclusion and respect.

A different outcome might have left Costa Rica in the unusual position of lagging behind Latin America in individual freedom, because several other countries, including Argentina and Colombia, have already adopted same-sex marriage. For now, the country still occupies its customary position in the democratic forefront. Nevertheless, seven decades since its inception, Costa Rica’s democratic experiment is showing some of the same signs of wear and tear that better-known counterparts in Europe and North America exhibit: the decay of traditional political parties, corruption scandals, rising income inequality and a surge in violent crime.

Concern over these problems may have fueled Costa Rica’s political volatility as much as the issue of gay rights. Yet in turning to Mr. Alvarado Quesada, the people showed an admirable resistance to demagoguery and single-issue politics. It will be up to the new president to show that they were right to place their trust, once again, in the democratic values and institutions that have served this remarkable country so well.

For the first time in the country’s history, a black woman will be Costa Rica’s vice president. Here’s what you need to know about Epsy Campbell Barr.