Seven people were detained when military forces stormed a tanker suspected to have been hijacked off the Isle of Wight.
Sixteen members of the Special Boat Service (SBS) ended a 10-hour standoff which started when stowaways on board the Liberian-registered Nave Andromeda reportedly became violent.
The stowaways, believed to be Nigerians seeking UK asylum, were handed over to Hampshire Police on Sunday night.
The 22 crew members were found safe.
The ship later docked in Southampton.
According to BBC defence correspondent, Jonathan Beale, British forces descended on to the vessel by rope from four Royal Navy helicopters after nightfall.
“The seven stowaways – believed to be Nigerians seeking asylum in the UK – were detained and handed over to Hampshire Police,” he said.
The Ministry of Defence called the incident a “suspected hijacking” and said Defence Secretary Ben Wallace and Home Secretary Priti Patel authorised the operation in response to a police request.
Mr Wallace said: “In dark skies, and worsening weather, we should all be grateful for our brave personnel. People are safe tonight thanks to their efforts.”
Mrs Patel tweeted she was “thankful for the quick and decisive action of our police and armed forces who were able to bring this situation under control, guaranteeing the safety of all those on board”.
Mr Beale said the individuals were detained after they were met with “overwhelming force”.
He said along with the SBS squad, a team of Royal Navy divers was deployed in one of the Royal Navy helicopters in case the vessel had been mined – but it had not.
Frank Gardner, BBC News security correspondent says
The operation by Special Boat Service commandos is exactly what this elite and secretive unit trains intensively for.
The SBS, headquartered at Poole in Dorset, is less well-known than its Hereford-based counterpart, the Special Air Service (SAS), but both units have been called on over the years for delicate counter-terrorism and hostage rescue missions, often in arduous conditions.
“Fast-roping” down from helicopters at sea and at night can be fraught with dangers but it often results in taking assailants by surprise – this operation took just nine minutes.
It would not have been possible though, if the crew had not followed a maritime drill enshrined in the manual called BMP5 – Best Management Practice 5th edition.
Withdrawing to the ship’s strong room known as “the citadel” and locking themselves inside meant they were able to call for assistance from a secure space.
In most cases of maritime piracy off Somalia hostage rescues were only ever undertaken if all the crew were safely inside the citadel.
Presentational grey line
The 748ft-long (228m) ship is known to have left Lagos in Nigeria on 5 October, and was heading to Fawley Oil Refinery near Southampton.
As it approached its destination just east of the Isle of Wight on Sunday morning it was reported that seven stowaways on board had become violent.
Lawyers for the vessel’s owners – Greek shipping company Navios – said the crew had been aware of the stowaways on board for some time.
Concerns over the crew’s welfare were raised at 10:04 GMT when the vessel was six miles off Bembridge, police said.
The 22 crew members locked themselves in the ship’s citadel – secure area – and were safe.
A three-mile exclusion zone was put in place around the vessel.
Tobias Ellwood, chairman of the Commons Defence Committee, said the boarding of the tanker was a “good outcome”.
He said: “Seven stowaways on board taking over a ship or causing the ship not to be in full command would have triggered a multi-agency alarm and then well-rehearsed classified protocols were then put into action.”
Hampshire Constabulary said late on Sunday: “Police are investigating this incident and we have a number of inquiries to carry out to establish the full circumstances.”
Bob Sanguinetti, chief executive of the UK Chamber of Shipping, told BBC Radio 4’s Today programme: “Nothing at this stage suggests that this was hijacking and in fact hijacking of this nature is extremely uncommon.”
In December 2018, four stowaways were detained after they ran amok on a container ship in the Thames Estuary.
The men, from Nigeria and Liberia, waved metal poles and threw faeces and urine after being found hiding on the Grande Tema.