Seven people have been arrested on suspicion of seizing control of an oil tanker, police have said.
The men were detained when military forces stormed the Nave Andromeda which was thought to have been hijacked off the Isle of Wight on Sunday night.
Sixteen members of the Special Boat Service (SBS) ended a 10-hour stand-off which started when stowaways on board the ship reportedly became violent.
Defence Secretary Ben Wallace said there had been a "threat to life".
Hampshire Constabulary said the seven men were being held on suspicion of "seizing or exercising control of a ship by use of threats or force under Sections 9(1) and (3) of the Aviation and Maritime and Security Act 1990".
"All 22 crew members are safe and well and the vessel is now alongside in the port of Southampton," a spokesman said.
Investigators are now speaking to the ship's crew to establish what happened.
The stowaways, believed to be Nigerians, were handed over to Hampshire police on Sunday night.
Mr Wallace said: "What was emerging was a clear threat to life on the ship and at that point the police made representation to the Ministry of Defence that they didn't have the capability to do what was needed in these challenging circumstances.
"We were under the awareness that the suspects were also threatening to do something with the ship.
"If they were threatening to take control of the ship then, of course, that is a hijack and the threat to the environment and, more importantly, to the lives of people on the ship is something the state can't tolerate."
BBC defence correspondent Jonathan Beale said 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.
Former Royal Navy officer Rear Adm Chris Parry said the operation to take control of the ship was over in "under nine minutes".
He said; "From the time the helicopters went in and the SBS roped on to the ship, they rounded up the people pretty quickly.
"I think the stowaways themselves accepted this was probably the end of the journey for them and there probably wasn't any point in resisting heavily armed men approaching them."
Navios Tanker Management, operator of the crude oil tanker, said the master of the Liberian-registered vessel became concerned for the safety of the crew "due to the increasingly hostile behaviour of the stowaways" who had "illegally boarded" in Lagos, Nigeria.
In a statement released on Monday, the company thanked the UK authorities for their "timely and professional response".
"Navios would also like to pay tribute to the master of the Nave Andromeda for his exemplary response and calmness and to all the crew for their fortitude in a difficult situation," it added.
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.
The Ministry of Defence called the incident a "suspected hijacking" and said Mr Wallace and Home Secretary Priti Patel had authorised the operation in response to the police request.
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 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.
Mr Beale said a defence source confirmed the master of the ship was on the bridge and in control of the vessel at all times, while the rest of the crew was locked away safely in a secure area.
The 748ft-long (228m) ship left Lagos on 5 October bound for Southampton.
As it approached the Isle of Wight on Sunday morning it was reported that seven stowaways on board had become violent.
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."
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.