His fans and supporters in the courtroom erupted in cheers after the detention decision. “There is a God,” said Rocky’s mother, Renee Black.

Rocky’s arrest and jailing a month ago precipitated an outpouring of support and anger, with celebrities, fans, congressmen and eventually President Trump demanding his release. Mr. Trump went so far as to send his special envoy for hostage affairs to the trial. But the Swedish authorities ordered Rocky to remain in jail as a flight risk before and during his trial, which ended on Friday.

The judge did not require Rocky or his two co-defendants, Bladimir Corniel and David Rispers, to remain in Sweden.