Article 27: Criminal jurisdiction on board a foreign ship

1. The criminal jurisdiction of the coastal State should not be exercised
on board a foreign ship passing through the territorial sea to arrest any person or to conduct any investigation in connection with any crime committed on board the ship during its passage, save only in the following cases:
(a) if the consequences of the crime extend to the coastal State;
(b) if the crime is of a kind to disturb the peace of the country or
the good order of the territorial sea;
(c) if the assistance of the local authorities has been requested by
the master of the ship or by a diplomatic agent or consular
officer of the flag State; or
(d) if such measures are necessary for the suppression of illicit
traffic in narcotic drugs or psychotropic substances.
2. The above provisions do not affect the right of the coastal State to
take any steps authorized by its laws for the purpose of an arrest or
investigation on board a foreign ship passing through the territorial sea after leaving internal waters.
3. In the cases provided for in paragraphs 1 and 2, the coastal State
shall, if the master so requests, notify a diplomatic agent or consular officer of the flag State before taking any steps, and shall facilitate contact between such agent or officer and the ship’s crew. In cases of emergency this notification may be communicated while the measures are being taken.
4. In considering whether or in what manner an arrest should be made,
the local authorities shall have due regard to the interests of navigation.
5. Except as provided in Part XII or with respect to violations of laws
and regulations adopted in accordance with Part V, the coastal State may not take any steps on board a foreign ship passing through the territorial sea to arrest any person or to conduct any investigation in connection with any crime committed before the ship entered the territorial sea, if the ship, proceeding from a foreign port, is only passing through the territorial sea without entering internal waters.
Source: UNCLOS