Brazilian prosecutors charged American journalist Glenn Greenwald on Tuesday with cybercrimes for his reporting last year on leaked cellphone messages that cast doubt on the impartiality of a corruption investigation that helped pave the way for the rise of Brazilian President Jair Bolsonaro.

News of the criminal complaint sent shock waves through Brazilian society, with journalists and others denouncing it as a politically motivated attempt to stifle free speech and a threat to Brazilian democracy. Greenwald called the allegations baseless.

Prosecutors in the capital, Brasilia, accused Greenwald of being a member of a “criminal organization” that allegedly hacked the cellphones of several public officials and copied messages that were then published last year on Greenwald’s news site the Intercept Brazil.

Greenwald, who lives in Rio de Janeiro, has published several investigations based on leaked messages alleging that the public corruption investigation into former Brazilian president Luiz Inácio Lula da Silva was tainted.

The Intercept Brazil reported allegations that Sérgio Moro, the judge who’d overseen Lula’s case, had colluded with prosecutors to convict him. Moro sentenced Lula, who was running for president and leading in the polls, to nine years in prison.

After Bolsonaro won the election, he appointed Moro as his justice minister.

Greenwald told The Washington Post last year that the messages were given to him by a person he would not identify. He said Tuesday the charges against him highlight authoritarian tendencies in a government he has accused of silencing critics and cracking down on the media.

“In a way, these kinds of battles are battles that are determining what kind of country you’re going to have,” he said in a brief interview. “And this is one of the first tests of what kind of government this will be.”

Greenwald won a Pulitzer Prize in 2014 for his reporting about Edward Snowden’s leaked files about the National Security Agency. He moved to Rio de Janeiro several years ago and is married to a Brazilian congressman, David Miranda, who is staunchly anti-Bolsonaro.

Greenwald hasn’t been arrested pending a judge’s decision to move forward.

In a longer statement to the Daily Beast on Tuesday, Greenwald said: “Less than two months ago, the Federal Police, examining all the same evidence cited by the Public Ministry, stated explicitly that not only have I never committed any crime but that I exercised extreme caution as a journalist never even to get close to any participation. Even the Federal Police under Minister Moro’s command said what is clear to any rational person: I did nothing more than do my job as a journalist — ethically and within the law.”

He called the charges “an obvious attempt to attack a free press in retaliation for the revelations we reported about Minister Moro and the Bolsonaro government. . . . We will not be intimidated by these tyrannical attempts to silence journalists.”

The conviction and imprisonment of liberal da Silva fed a wave of discontent that contributed to the election of Bolsonaro, a populist former congressman and military officer who has appealed to nationalism, homophobia and nostalgia for Brazil’s former military dictatorship.

Sometimes called “the Trump of the tropics,” Bolsonaro has frequently attacked the news media as part of his anti-establishment rhetoric.

The charges against Greenwald have alarmed Brazilian journalists and press-freedom advocates, who see the case as a test for the media.

“Of course, I cannot speak on behalf of Brazilian journalists, but I believe a majority would agree with me in saying the charges against Greenwald are an attempt to intimidate him and by extension the practice of independent journalism in Brazil,” said Carlos Eduardo Lins da Silva, a longtime Brazilian journalist who is a professor at the Insper university in Sao Paulo.

Caio Tulio Costa, the former editor and ombudsman of Folha de Sao Paulo, one of Brazil’s leading daily newspapers, said the charges are “yet another case of violence practiced by the Brazilian State. . . . A journalist has the duty and the right to speak to his sources, whoever they may be, and this is part of the soul of the profession. Inadmissible on all counts. Our democracy is in danger.”

Brazilian author and journalist Eugenio Bucci said the accusations against Greenwald could violate Brazil’s constitutional guarantee of confidentiality between sources and journalists. “More than that, it appears as a threat against all journalists,” he said. “It is a clear menace against freedom of press.”

Ben Wizner, director of the American Civil Liberties Union’s Speech, Privacy, and Technology Project, called on the U.S. government to condemn “this outrageous assault on the freedom of the press, and recognize that its attacks on press freedoms at home have consequences for American journalists doing their jobs abroad.”

Natalie Southwick, the coordinator of the Committee to Protect Journalists’ Central and South Americas program, called the charges “cause for concern.”

“Charging a journalist with criminal activity based on interactions with sources sends a chilling message to reporters working on sensitive stories at a time when the Brazilian media is increasingly under attack from officials in its own government.”

Greenwald also denounced Brazil’s president: “The Bolsonaro government and the movement that supports it has made repeatedly clear that it does not believe in basic press freedoms.”

Staff writer Terrence McCoy in Brazil contributed to this report.