RIO DE JANEIRO — Reading through the hacked cellphone messages of Brazilian prosecutors and judges, Glenn Greenwald knew he had a blockbuster story.

Mr. Greenwald, an American journalist, figured he was well equipped to weather the blowback. After all, he played a central role in exposing the secret intelligence programs leaked by Edward Snowden, the national security contractor, five years ago.

“I assumed it was going to be very similar to the Snowden story,” Mr. Greenwald said. “I’m going to know how to do this.”

He greatly underestimated.

The cellphone messages sent shock waves through Brazil when the news organization Mr. Greenwald co-founded, The Intercept Brasil, wrote about them last year, raising doubts about the fairness of the vast corruption investigation that upended the country and ultimately helped pave the way for the election of Brazil’s far-right president, Jair Bolsonaro.