VALLETTA, Malta — Three teenage migrants have been charged in a court in Malta with hijacking a small commercial oil tanker that had rescued them and others off the coast of Libya, an act that is considered a terrorist crime under Maltese law.

The tanker, El Hiblu 1, was hijacked in the Mediterranean this past week. The captain said that rescued migrants had begun to riot and threaten violence when they saw that the ship was returning them to Libya. According to the captain, they forced it to turn north toward Europe.

The suspects pleaded not guilty during an arraignment in Valletta, the Maltese capital, on Saturday. One of the accused was identified by the court as Abdalla Bari, a 19-year-old from Guinea. The other two are a 15-year-old from Guinea and a 16-year-old from Ivory Coast, who could not be named because they were minors.