RIO DE JANEIRO — A federal judge in Brazil on Thursday dismissed criminal charges against the American journalist Glenn Greenwald, sparing him for now from being prosecuted for his role in the release of hacked cellphone messages that have embarrassed prosecutors and prominent officials.

Judge Ricardo Leite said in a 10-page ruling that the criminal case against Mr. Greenwald could not move forward because he was shielded by a Supreme Court justice’s order, issued in August, that barred law enforcement officials from investigating the journalist’s role in the hacking case.

Experts in criminal law in Brazil were critical of the decision to charge Mr. Greenwald, 52, with cybercrimes, arguing that the criminal complaint filed against him did not clearly implicate the journalist in criminal conduct. Brazil has strong legal protections for reporters.

Judge Leite’s ruling, however, was far from exculpatory. He wrote that messages exchanged between Mr. Greenwald and his source portray the journalist “as an instigator of the conduct of the other defendants and not merely a receiver of illegal content.”