I was a child when I saw Terry Gilliam’s Brazil for the first time. I expected a film about the stereotypes of my country – carnival, samba and football – but found something else. In Gilliam’s surrealist story, the state imprisons, tortures and kills anyone it sees fit. Human rights disappear in a Kafkaesque maze.

I met Gilliam 20 years later. He came to a screening in London of my film The Edge of Democracy, which chronicles Brazil’s recent political crisis. He told me he was inspired to name his film Brazil not only by the famous song but also by the Latin American dictatorships of the 1970s. As I made my film, the dystopian future once imagined by Gilliam was now a reality captured by our cameras.

In early 2016, I filmed a street protest in Copacabana. Hundreds of thousands of people were calling for the impeachment of our first female president, Dilma Rousseff, and the imprisonment of ex-president Luiz Inácio Lula da Silva. I even saw some groups calling for the return of the military dictatorship. I left that protest deeply troubled by the fact that people were asking for the return of a regime that had killed hundreds and tortured thousands.

Rousseff’s impeachment went ahead, despite the fact that most congressmen could not explain what she was actually being tried for. “I am Josef K,” Rousseff said to our camera, in reference to Kafka’s The Trial. In my assessment, Rousseff’s government was guilty of the kind of garden-variety “creative accounting” that does not rise to the level requiring impeachment.

Two weeks after Dilma was impeached, the prosecutor’s office accused her predecessor, Lula, of being responsible for an unprecedented corruption scheme named Car Wash. Yet the proof was dubious: an apartment that was not in his name, for which he did not have the key, and where he hadn’t slept a single night. After a fast-tracked trial, Lula was sentenced to 12 years in prison.

Operation Car Wash exposed a longtime corruption scheme involving contractor executives and many politicians, several of them members of Lula’s Workers’ party. For the first time in Brazil’s history, politicians and businessmen were no longer protected by a veil of impunity. While this, on the whole, represented a positive development, there were significant downsides: from the beginning the operation allegedly used questionable procedures, such as selectively leaking information to the media and detaining people before they were convicted in order to force confessions.

In June 2019, the Intercept published a trove of leaked Telegram messages in which Sérgio Moro, the judge overseeing Car Wash, offered prosecutors advice on how to prevent Lula from running in the 2018 election.

Lula was the frontrunner; if he hadn’t been imprisoned he probably would have won. Instead, he went to jail, and Jair Bolsonaro was elected in his place. Bolsonaro’s first action was to name Moro minister of justice.

This November, Lula was released following a supreme court decision affirming the country’s 1988 constitution. Everyone has the right to exhaust their appeals before they’re imprisoned, the court ruled. In 2016, federal judges had ignored that same constitutional principle because of the mounting political pressure to expose Operation Car Wash.

Since Bolsonaro’s election the destruction of the Amazon rain forest has increased dramatically, with a territory almost the size of Lebanon already deforested. A number of indigenous leaders have been assassinated, and police killings have spiked by 20%. When questioned about how to end violence in Brazil, Bolsonaro suggested police should be able to kill with impunity and suspects should “die in the streets like cockroaches”. The message was clear, and the targets have an obvious skin color, social class and address.

In the last several months, poverty and inequality have sparked protests throughout Latin America. In response – and no doubt fearful of Lula’s ability to organize the opposition – Brazil’s finance minister recently made a thinly veiled threat, telling reporters not to be surprised if the government restores AI-5, a dictatorship-era decree used to close congress and suppress dissent.

Bolsonaro himself has flirted with the possibility of invoking a national security law to imprison Lula. This comes from a man who has, in recent months, praised dictators such as Augusto Pinochet and has even argued that in 1964, there was no coup d’etat in Brazil.

His son, Eduardo, chair of the foreign affairs committee of the national congress, has warned that if the protests roiling other Latin American countries reach Brazil, the government may adopt measures used during the military dictatorship to suppress them.

Donald Trump’s former strategist, Steve Bannon, who supports Bolsonaro, recently expressed his fear of Lula’s release: “He is the leader of the globalist left now that Obama is out of politics.” Since Bannon is a chief mouthpiece of the new international far right, those worried about the erosion of democracy worldwide should pay close attention to what happens to Lula and Brazil in the coming months.

If you land in Rio these days, you won’t find tanks on the streets, nor will you hear about journalists being arrested. But don’t be fooled. The Brazilian far right, with the aid of the government itself, is executing a well-planned strategy to shrink the liberal democratic sphere. NGOs and civil society groups have been marginalized from policymaking. The rule of law faces death by a thousand cuts.

Safeguarding democracy is a daily struggle, and we are now especially vulnerable to the ravages of populism. The far right will always marshal imaginary enemies – whether they be communism, immigration or an overweening EU – to consolidate power and dismantle the pillars of democracy.

Lula’s case is, of course, as controversial as ever. I have realized, however, that what each person believes about Lula’s guilt and innocence is not important. What matters is evidence and due process. This is what protects all of us and separates democracy from dictatorship.

As the far right spreads, a crucial vaccine to this epidemic is the rule of law. Otherwise Brazil will once again become “Brazil”, the worst version of its surrealist nightmare, and fascism will not stop within its borders.