Costa Rica goes to the polls this weekend for a presidential runoff election in which economic concerns have unexpectedly been overshadowed by a debate over gay marriage.

The current frontrunner – rightwing evangelical candidate Fabricio Alvarado – leapfrogged 12 rivals to win February’s first-round vote, largely thanks to his pledge to ignore an Inter-American Court of Human Rights ruling which warned Costa Rica that it must guarantee same-sex couples equal rights to marriage.

What was even more remarkable than his sudden electoral surge was that Alvarado had managed to make the election in Central America’s most stable democracy hinge on an abstract – some would say specious – concept: “gender ideology”.

The phrase is neither a legitimate academic term, nor a political movement.

It is a theory drummed up by hard-right religious activists, who present it as a gay- and feminist-led movement out to upend the traditional family and the natural order of society. It’s a catchall phrase to sell a false narrative and justify discrimination against women and LGBT people. And it is winning elections.

The term first surfaced in the Vatican, in the mid-1990s, a time when sexual and reproductive rights were formally recognised by the UN, and when gender entered the lexicon of the global body. Gender equality was finally being protected and promoted by international legal obligations.

Advances in women’s rights threatened the Catholic church, which feared this would open the floodgates to abortion and promiscuous behaviour, and lead to the downfall of western civilisation.

By 1997 the notion of a “gender ideology” gained wider momentum with the publication of Dale O’Leary’s The Gender Agenda. This influential text – reportedly read by members of the Vatican – maintained that substituting the word “sex” with “gender”, in international spaces like the UN was part of a global feminist scheme to dissolve the family and remake society.

By the early 2000s, a transnational movement agitating against “gender ideology” was strengthening. And not just in Catholic Poland, Brazil and Ireland, but in reliably progressive countries like Germany and France.

One of the most remarkable deployments of gender ideology was during the 2016 Colombia peace referendum. After 52 years of civil war, Colombians were widely expected to vote for a peace accord. Yet in a stunning setback, voters rejected the deal by a narrow margin. It was Latin America’s Brexit moment.

One contributing factor was a fear campaign launched by peace opponents. They framed efforts to address gender-based violence and to ensure the political participation of women and LGBT people as the work of gender ideologues out to subvert the traditional family and Colombia’s Christian values.

In Costa Rica and Colombia, activists were able to weaponise the term to attack secular human rights institutions, and in the process, reclaim Christian cultural primacy. But its value lies in its ambiguity.

Because the term is so ill-defined and misunderstood, it can be repackaged for any country and any context.

In Europe, it is often used by anti-Muslim and anti-immigrant parties. The connection may at first not seem obvious – most observant Muslims do not support abortion or LGBT rights.

But rightwing populists imply that both Muslims and pro-choice, and pro-LGBT defenders have an interest in the destruction of western society, that both benefit from anti-discrimination policies and protections – and that both are out to remake and dominate the political and social order.

In Europe, even mechanisms to protect women from gender-based violence, such as the Istanbul convention, are being attacked for pushing a covert agenda.

Elsewhere, the spectre of “gender ideology” has been deployed to help purge ministries that protect women. This happened in Austria – which in 2000 folded its women’s ministry into the ministry for social affairs – and also in Brazil and Costa Rica. And we can’t talk about eliminating protections for women without mentioning Trump’s funding cuts to the Office of Global Women’s Issues.

In Costa Rica, Alvarado has promised that if elected, he will not only ignore the Inter-American Court of Human Rights ruling, but would also pull the country out of the Organization of American States, the oldest international institutional system dedicated to human rights and democracy.

Ultimately, what’s being targeted is the infrastructure of democracy.

This is the genius of the anti-gender ideology formula. Its plasticity to be secular and anti-Muslim in Europe, and unapologetically Christian in Latin America. The term is no longer part of the Catholic rightwing vernacular, but that of a transnational conservative movement dedicated to preventing, and even undoing, progress on women’s and LGBT rights.