If a cruise ship is a floating city, then the captain is its mayor.

But when it comes to law and order, there is no police force and no courts. That can leave victims of crime aboard the ship unprotected — because it is not clear which laws apply.

A reported sexual assault case aboard a Mediterranean cruise ship last week highlighted that legal ambiguity when a Spanish judge released the detained suspect after the ship docked in Valencia. The judge declared that Spain had no jurisdiction in the case because the alleged crime was said to have taken place in international waters, according to a report by the Spanish newspaper Levante.

If Spain cannot prosecute, then which country can?

“There’s no cut-and-dried rule,” said Frederick Kenney, the director of legal affairs and external relations for the International Maritime Organization, a United Nations agency responsible for global shipping safety.

“There is no international law that covers this situation at the moment,” he said.

Maritime law establishes that a ship is subject to the laws of the country whose flag it flies. But for tax reasons and other legal advantages, few cruise ships are flagged with the countries of their home port, or even their corporate headquarters.