The master of a UK-bound container ship has told a court he locked four stowaways in quarantine after fearing they may have been Boko Haram terrorists.

Antonio Raggi said he was "very worried" about the safety of his 27 unarmed crew members after discovering the men aboard the Grande Tema six days into a voyage from Lagos, Nigeria to Tilbury.

Three Nigerians and a Liberian allegedly armed themselves with metal poles and threatened to kill the crew after breaking out of their detention in a desperate bid to reach Britain.

Asked why he locked the men up after discovering them, Mr Raggi told the Old Bailey in a strong Italian accent on Wednesday: "For me, these guys could be terrorists, Boko Haram, I don't know.

"They come on board, they break the safety, the security of the vessel.

"My problem is if these guys have put something in a part of the vessel and after are going to come and get weapons."

Mr Raggi said the men, who had no identity papers, were discovered in a "very dangerous" lower area of the ship near a broken-in door as it sailed near the Canary islands.

He said he then persuaded them to leave the area, where they were clothed, fed and watered, and given showers.

Mr Raggi told the court: "These guys were without documents, any identification. For me it's very suspect when I find the door broken.

It's incredible."

He said the only safe living area for them was the quarantine room and that a ship's master effectively acts as the police under Italian rules in international waters.

He also said Italian legislation dictates that weapons are forbidden on the ship, meaning his crew were unarmed.

But after five days in quarantine, the men allegedly broke free and ran amok, arming themselves, making throat-cutting gestures and hurling faeces as most of the crew retreated to the safety of the bridge.

The 14-hour stand-off was brought to an end when special forces swooped under the cover of darkness in the Thames Estuary late on December 21 last year, the court has heard.

Samuel Jolumi, 27, Ishola Sunday, 28, Toheeb Popoola, 27, and Joberto McGee, 20, have denied attempting to hijack the ship, making threats to kill, and affray.

Asked about security precautions before leaving the Nigerian port by prosecutor Tony Badenoch QC, Mr Raggi replied: "The pier in Lagos is particular.

"There is a pillar by the entry which is very easy with one canoe or something to go inside the pier and to jump on the vessel.

"There are people checking when the ramp is closed, watchmen checking nobody jumps on-board.

"There is also razor wire on ladders to protect the vessel.

"We also put grease down in the ramps."

Terror threats in places like Nigeria also contribute toward stringent security checks and searches before the ship departs, he told the court.

The Italian-flagged ship was operating on the second of three security levels, meaning sweeps of the ship were completed every hour, he said.

In particular, areas of "vital importance" were checked, including the bridge, the generator and engine room, jurors heard.

The Grande Tema weighs unladen some 78,000 tonnes, is 232 metres long, 32 metres wide and approximately 38 metres above the water line.

The container vessel operated by the Grimaldi Group is heavier than the UK's largest aircraft carrier, and only slightly shorter in length than the Houses of Parliament, Mr Badenoch said.