SÃO PAULO, Brazil — A Brazilian court has dismissed the criminal case against the American swimmer Ryan Lochte, who was charged with filing a false robbery report during the 2016 Olympics in Rio de Janeiro.

The court confirmed in a statement that it tossed out the case after determining that Lochte’s robbery claim made to NBC did not constitute the filing of a fake report, a crime punishable by up to 18 months in prison.

“We are pleased that the court has finally dismissed the criminal prosecution against Mr. Lochte, while also acknowledging that he committed no crime while in Brazil,” Jeff Ostrow, Lochte’s Florida-based attorney, said in an email to The Associated Press on Saturday. “We are hopeful that the prosecution accepts the court’s decision so that this story can finally be put to rest.”

Lochte told NBC last year that he and his fellow swimmers Jack Conger, Gunnar Bentz and Jimmy Feigen were robbed at gunpoint in a taxi by men with police badges as the swimmers returned to the Olympic Village after a party on Aug. 15.