SAO PAULO (AP) -- A Brazilian federal court has dismissed criminal charges filed last year against Chevron (NYSE:CVX), driller Transocean (NYSE:RIG), and several of their executives in connection with a 2011 oil spill off the coast of Rio de Janeiro.

The two companies and 17 of their executives had been charged with "crimes against the environment" and faced up to 31 years in prison if convicted.

Judge Marcelo Luzio sent the charges back to prosecutors, who have five days to appeal his ruling, a court official said Thursday. The official did not provide further details. She spoke on condition of anonymity because she was not authorized to speak to the news media.

The prosecutor's office said it would not have any immediate comment.

Chevron said in a statement that it was pleased by the court's decision and that it remained "committed to its policy of full transparency and close cooperation with Brazilian authorities."

Transocean said it welcomed the ruling, which it said showed that "Transocean's crew members did exactly what they were trained to do, acting responsibly, appropriately and quickly while always maintaining safety as their top priority."

The companies still face two civil lawsuits seeking $20 billion in damages for the spill, in which about 155,000 gallons of crude oil leaked from the seabed near a Chevron well off the coast in November 2011.

"Both sides are seeking an agreement regarding the amount to be paid," said Marcelo Del Negri, a spokesman at the federal prosecutor's office. "All I can tell you is that they have offered to pay far less than what we want -- about $160 million."