The British Government has been accused of wilfully trapping thousands of refugees at risk of rape, torture and imprisonment in Libya by increasing efforts to stop them fleeing across the Mediterranean.

During a visit to Tripoli, Boris Johnson vowed that the UK would support the fragile Libyan Government of National Accord (GNA) to “reduce the number of illegal migrants heading for Europe”.

“Libya is the front line for many challenges which, left unchecked, can pose problems for us in the UK – particularly illegal migration and the threat from terrorism,” the Foreign Secretary said.

“That’s why it is so important that we work with the Libyan government and our partners to help bring stability to Libya, stopping it from becoming a fertile ground for terrorists, gun runners and people traffickers in close proximity to Europe.”

Mr Johnson said that as well as supporting an unspecified “political process”, the UK was backing “practical efforts … to ensure the Libyan coastguard can secure their own borders, reducing the number of illegal migrants heading for Europe”.

The statement incensed humanitarian groups running search and rescue missions in the central Mediterranean, where more than 2,400 men, women and children have drowned while attempting to reach Europe so far this year.

NGOs are bearing the brunt of increased aggression displayed by the Libyan coastguard, seeing armed officers block rescues, board migrant dinghies and open fire while attempting to seize control of the search and rescue zone in international waters from the Italian government.

Boris Johnson meets members of the Libyan coastguard at a naval base in Tripoli (PA)

The coastguard, which is being trained by the Royal Navy and EU partners, stands accused of killing, shooting and abusing migrants and attacking aid workers but has benefited from substantial funds and equipment from Italy.

Fearing for their safety, several groups have withdrawn their ships as political and public support from Europe wanes and unproven allegations of “collusion” with Libyan people smugglers gain traction.

Médecins Sans Frontières (MSF), which had one of its ships fired on by the Libyan coastguard in an incident verified by The Independent last year, accused the British Government of attempting to shirk responsibility for the refugee crisis and instability in Libya – whatever the cost.

Andre Heller-Perache, the charity’s UK head of programmes, said: “What Boris Johnson notably fails to mention is the multiple occasions – as recent as last week – on which the UK-trained Libyan coastguard has threatened, or even fired upon, NGO search and rescue vessels operating in international waters.

“This shows that the British Government is happy to sweep the appalling human cost of its deterrence policies on migration under the carpet – anything to make this someone else’s problem.”

Mr Heller-Perache said MSF staff had met migrants in squalid Libyan detention centres who were taken there by the coastguard, accusing the UK of “helping to trap thousands of people in appalling conditions”.

“Its policy is pushing refugees and migrants into the hands of criminals and people traffickers, contributing to the very problem the Government claims to want to solve,” he added.

Damage from bullets fired by the Libyan coastguard below the bridge on MSF ship the Bourbon Argos (Lizzie Dearden ) (Lizzie Dearden)

“The Foreign Secretary can no longer remain silent on this issue – he has serious questions to answer on the harm caused by Britain’s support for the Libyan coastguard, and the role that it plays trapping people in Libya.”

A statement issued by the Foreign Office (FCO) made no direct mention of the rival Libyan government based in Tobruk, which has a substantial army led by Russia-backed general Khalifa Haftar.

The country has been locked in a brutal civil war since the British-backed removal of dictator Muammar Gaddafi in 2011, and remains divided between the two main rival governments and countless warring militias.

Widespread lawlessness has let people smugglers set up a ruthless trade kidnapping migrants, mostly from sub-Saharan Africa, and ransoming them or forcing them into labour and prostitution.

The United Nations has issued repeated warnings over horrors including “slave auctions”, rape and torture awaiting migrants in the country, which make any attempt to forcibly return asylum seekers to its shores from international waters a violation of international law.

Terrorist groups including al-Qaeda factions have capitalised on the ongoing power vacuum, with Isis still controlling pockets of territory despite losing its coastal stronghold of Sirte last year.

In pictures: A day of refugee rescues in the Mediterranean Sea Show all 7 1 /7 In pictures: A day of refugee rescues in the Mediterranean Sea In pictures: A day of refugee rescues in the Mediterranean Sea A baby being taken on to MSF's Bourbon Argos ship from a boat carrying 130 migrants and refugees Lizzie Dearden In pictures: A day of refugee rescues in the Mediterranean Sea A refugee boat carrying 101 people being rescued by MSF's Bourbon Argos Lizzie Dearden In pictures: A day of refugee rescues in the Mediterranean Sea A refugee boat carrying 101 people being rescued by MSF's Bourbon Argos all images by Lizzie Dearden In pictures: A day of refugee rescues in the Mediterranean Sea A baby among refugees on a boat carrying 185 people off the coast of Libya Lizzie Dearden In pictures: A day of refugee rescues in the Mediterranean Sea Migrants and refugees sleeping after being rescued by MSF's Bourbon Argos ship Lizzie Dearden In pictures: A day of refugee rescues in the Mediterranean Sea A crew from MSF's Bourbon Argos ship rescuing a boat carrying 130 migrants and refugees off the coast of Libya, at sunrise Lizzie Dearden In pictures: A day of refugee rescues in the Mediterranean Sea A woman in a stretcher being lifted onto MSF's Bourbon Argos ship from a boat carrying 130 migrants and refugees off the coast of Libya Lizzie Dearden

The group made its presence brutally felt on Wednesday when militants massacred at least nine members of General Haftar’s forces and two civilians.

A statement from its Amaq propaganda agency said 21 members of “the Haftar militia” were killed and wounded at a checkpoint in the central Jufra region, where the so-called Libyan National Army seized control of several strategic bases earlier this year.

The possibility of Isis using Libya as a base to launch international terror attacks and regroup from its shrinking territories in Iraq and Syria has sparked alarm that increased after it emerged that the Manchester Arena bomber may have undergone terror training there.

The security situation in Libya is so dire that the FCO advises against all travel to any part of the country, and has urged all British nationals still present to leave immediately, having closed the Tripoli embassy.

“Although the Government of National Accord (GNA) is working to restore stability and security to Libya, intense fighting continues in a number of areas and local security situations are fragile and can quickly deteriorate,” the official advice reads.

“Terrorists are very likely to try to carry out attacks in Libya. There remains a high threat throughout the country of terrorist attacks and kidnap against foreigners.”

Such is the danger that Mr Johnson’s trip, the second in under six months, was not announced in advance under advice from Britain’s security services.

Isis still controls parts of Libya (Reuters)

The Foreign Secretary met Prime Minister Fayyez Al-Serraj, foreign minister Mohamed Siala and the President of Libya’s High State Council Abdurrahman Swehli.

An FCO statement said Mr Johnson “underlined the importance of Libya’s different political and social groups working together to overcome the current political conflict” – a conflict that world leaders including Barack Obama have directly blamed the UK for.

The Foreign Secretary announced new funding including £3m to remove improvised explosive devices left by Isis in Sirte, £1m for de-mining training across Libya, £1m to rebuild critical infrastructure and restore basic public services through the United Nations Development Programme, £2.75m to support women’s participation and £1.29m to help displaced people.

“The Government has also agreed to increase its engagement with the Libyan law enforcement authorities to tackle organised crime and trafficking, building on the work the UK is already doing with European partners to strengthen the ability of the Libyan coastguard to secure its own borders in a manner which respects international law,” a spokesperson said, adding that British training was focusing on “human rights and the treatment of migrants”.

Research by Oxfam found that all but one of the women questioned had suffered sexual exploitation in Libya and three-quarters of people fleeing through the country had witnessed murder or torture.

“It is disturbing that Boris Johnson is talking about preventing people who are fleeing violence and destitution at home from leaving Libya,” said Fionna Smyth, Oxfam’s head of humanitarian campaigns.