VALLETTA, Malta — A Maltese special operations team boarded a tanker carrying more than 100 migrants on Thursday that the authorities said had been hijacked by several of the people who had been rescued at sea, returning control to the captain and escorting it to port.

Armed military personnel stood guard on the ship’s deck, and a dozen or so migrants were also visible, as the vessel docked at Boiler Wharf in the Maltese city of Senglea. Several police vans were parked on shore to take custody of the migrants for investigation. Four men who were led off in handcuffs were believed to be suspects in commandeering the vessel.

The authorities in Italy and Malta said on Wednesday that the group had taken over the Turkish oil tanker El Hiblu 1 after being rescued in the Mediterranean Sea, and then forced the crew to put the Libya-bound vessel on a course north toward Europe.

In all, the Turkish tanker had rescued 108 people — 77 men, 19 women and 12 minors, including toddlers, at sea, Maltese officials said. One pregnant woman and one child were being treated at a hospital as a precaution.