CAMBRIDGE, Mass. — BRAZIL is potentially poised to become the third and largest country in Latin America to legalize same-sex marriage, following a judicial order on Tuesday. Argentina was the first, in 2010, after the government brushed aside objections from Cardinal Jorge Bergoglio of Buenos Aires, now the pope. The Uruguayan legislature followed suit last month. Mexico City has allowed such unions since 2010, and the Mexican state of Quintana Roo since 2011.

How can we reconcile these developments with the stereotype of Latin culture as a bastion of religiosity and machismo? How is it that the continent the Catholic Church looks to as its future (along with Africa) is home to what is said to be the largest gay-pride celebration in the world, in São Paulo, Brazil?

The church’s presence in Latin America is undeniable, but its influence on social policy is nothing like that of conservative Christian evangelicals in the United States, nor have the rising numbers of Pentecostals been obsessed with homosexuality like their conservative counterparts up north. Mexico, for instance, has long emphasized separation between church and state and recognizes only civil marriage — that is, clerics can officiate at weddings, but are not empowered to legally marry couples.

Political history is another factor. Since the 1970s, protest movements helped end military dictatorships or long periods of one-party rule; this democratic opening empowered left or center-left governments that have strongly emphasized human rights and individual freedom. Rafael de la Dehesa, a social scientist at the College of Staten Island, City University of New York, has shown how gay and lesbian activists piggybacked on this wave of democratization.