RIO DE JANEIRO — Had it gone as planned, an exhibition that opened last year in Brazil — which included a drawing of smiling children with the words “transvestite” and “gay child” stenciled across them — would likely have been a mere blip in the country’s lively art scene.
Gaudêncio Fidélis, the curator who assembled the 264 pieces that made up the “Queer Museum” exhibition, had expected at least a whiff of criticism for the art show. But nothing could have prepared him for the torrent of controversy that set off protests and shut down the exhibition within days.
Even after the show was closed, the storm of criticism kept the project in the news, inciting a heated, monthslong national debate about freedom of expression and what qualifies as art.
After nearly a year of arguments, the exhibition — which also included a painting of the Virgin Mary cradling a monkey, and sacramental wafers with words like “vagina” and “penis” written on them in neat cursive — reopened this month in Parque Lage, a public park in Rio de Janeiro that is also home to a renowned art school.
As he stepped to the podium earlier this month to preside over the opening ceremony, Mr. Fidélis looked ebullient as he flashed a victory sign.
“In the face of censorship and the shutdown of ‘Queer Museum,’ there was no alternative but to react and believe the future had this victory in store for us,” he said before a jubilant crowd, awash in the colors of the gay pride flag.
Despite his claim of an outright win, the opposition has no intention of surrendering the fight. Even as he spoke, a small group of protesters heckled him from a few feet away. They held Brazilian flags and religious signs, including one showing a smiling, white couple with three children under the words: “God created man in his image; he created a man and a woman.”
The contentious exhibition has cast a spotlight on the battle over gay and transgender rights in Brazil, Latin America’s largest nation.
Over the past decade, the region has marked notable gains for the movement for legal equality for gay and transgender people. Brazil, which began recognizing same-sex unions in 2004, became in 2013 one of the first countries in the Americas to legalize same-sex marriage.
São Paulo, the country’s largest city, hosts the world’s largest gay pride parade, and Rio de Janeiro has long been a popular destination for gay tourists.
But in Brazil, gay and transgender advocates have made inroads mainly through litigation, rather than legislation, while voters have elected increasingly conservative politicians.
There is one openly gay lawmaker in Brazil’s Congress, while 199 of the 513 representatives in the lower House belong to the so-called Evangelical caucus, which includes members who have championed conversion therapy for gays.
“The correlation between legal changes and greater social acceptance of L.G.B.T.I. people is not straightforward,” said Fabrice Houdart, a human rights officer at the United Nations who focuses on sexual orientation and gender identity issues like intersexuality. “In several places in Latin America, legal rights have changed much more quickly than attitudes.”
As the political arena has become increasingly hostile to the gay rights movement, activists have increasingly turned to the arts and the private sector to build grass-roots support.
That was one of the motivating factors that drove Fabio Szwarcwald, the head of Parque Lage art school, to resurrect the “Queer Museum” exhibition.
The school has never shied away from controversy. Founded in the 1970s while Brazil was under military rule, it became a hub for artists and intellectuals who pushed the boundaries of criticism during an era in which the press and speech were heavily censored.
To fund the show, Mr. Szwarcwald started a crowdfunding campaign, which raised more than $327,000, a record in Brazil.
The first fight over the “Queer Museum” exhibition erupted just days after it opened in early September last year at the cultural center of Banco Santander, one of the largest banks in Brazil, in Porto Alegre, a city in southern Brazil.
Many of the protesters were from the Free Brazil Movement, a conservative group that played a leading role in calling for the impeachment of leftist president Dilma Rousseff in 2016. They denounced artwork they saw as demeaning Catholic symbols and promoting zoophilia and pedophilia.
The church took up the cause, too.
The archdiocese of Porto Alegre issued a statement calling the works an “attack on the Judeo-Christian culture that contributed to the cultural formation of the West.” It added: “In times of terrorism and intolerance, you do not build bridges with aggression and disrespect for what is most intimate and sacred in the other: their faith and their body.”
As dueling camps of protesters gathered outside the cultural center last year, and the bank’s inboxes were flooded with critical messages, executives at Banco Santander decided to pull the plug on the show.
“We offer sincere apologies to those who saw disrespect for faith and symbols in the exhibit ‘Queer Museum,’” the bank said in a statement to its customers. “This is not part of our worldview or the values we support.”
Federal prosecutors took the bank to task for shutting down the exhibition and called on it to reopen it at once.
“Freedom of expression constitutes a constitutionally guaranteed right that is vital to human dignity,” prosecutors wrote in an opinion. But prosecutors could not compel the bank to act, and the opinion was disregarded.
If the bank had enjoyed the final word, Mr. Fidélis said, it would have set a dangerous precedent for freedom of expression in Brazil at a moment when its democracy is under strain amid deep political polarization. He argued that it would have also sent a chilling message to gay and transgender Brazilians, who are often the victims of hate crimes.
Mr. Fidélis first tried to move the exhibition to the Rio Art Museum. But soon after Mr. Fidélis began negotiating with museum officials, Marcelo Crivella, the mayor of Rio de Janeiro and an evangelical preacher, said the institution, which receives public funding, would not host it.
That is when the art school stepped in.
At an evening preview of the exhibition inside its new home in Rio de Janeiro, Bianca Kalutor, 30, a transgender woman, beamed with pride.
The provocative, transgressive pieces surrounding her made her feel at home — and safe, she said, giving her a sense of belonging that has eluded her from childhood.
“There are all these spaces in which queer people are questioned,” she said. “Being trans, you develop an ability to enter and leave spaces without being noticed.”
The following morning, on the day of the exhibition’s formal opening, a couple dozen protesters were among the first to arrive at Parque Lage. Carrying signs that said “zoophilia” and “pedophilia,” they chanted: “blasphemy cannot hide in art.”
Their chants were soon drowned out by a collective of female drummers.
Anticipating the possibility of violence, Parque Lage had hired additional security personnel and had an ambulance on standby. David Miranda, the city’s sole openly gay council member, took the opportunity to hand out campaign fliers seeking support for his bid for a seat in Congress.
“The L.G.B.T. population is starting to awaken politically,” Mr. Miranda said. “We need people to take notice of the violence that is happening on a daily basis.”
By the time the speeches were over, shortly after noon, the line to enter the exhibition stretched for well over a block. During its inaugural weekend, “Queer Museum,” which will be on display until Sept. 16, drew nearly 7,000 visitors.
“This turnout is evidence that Cariocas are not going to accept censorship,” Mr. Szwarcwald said, using the term for Rio de Janeiro residents.
But there was one final obstacle that troubled Mr. Szwarcwald, a father of two young boys. At the request of an evangelical City Council member, a judge had issued an order the day before the opening banning children 14 and under from visiting the exhibit.
On Tuesday, after another judge suspended that order, Mr. Szwarcwald and Mr. Fidélis smiled as they tore up the sign noting the prohibition.