The UK has had to scale back its commitment to counter-piracy because the Royal Navy no longer has enough warships to dedicate one to Somalia all year round.

While the US, France, Italy, Denmark and other nations still send frigates to thwart criminals who cause havoc with international trade, the Guardian has learned that Britain has quietly withdrawn its ships from these patrols, even though David Cameron has made Somalia's piracy problem a foreign policy priority.

Piracy cost the world economy $7bn (£4.3bn) last year. Figures show the pirates raised almost $160m from hostage ransoms, but 24 of their captives died.

British businessman David Tebbutt was one of their victims, and his wife, Judith, was held for six months before being released in March.

Because of defence cuts, the UK can deploy only two frigates for contingency operations east of the Suez canal. They have to cover a massive area of ocean stretching from the Gulf to the Falklands. Neither can be committed to piracy full-time, though HMS Westminster "dips in" when it can, sources say.

The navy's fuel and supply ship, the Fort Victoria, has been supporting the 16-strong counter-piracy fleet since last year, though it is unclear whether the vessel will continue to do so beyond the summer.

In the past, the UK has always managed to dedicate up to four frigates to Somalia, deployed on rotation to provide year-round support.

The squeeze was forced on the Ministry of Defence by cuts set out in the 2010 Strategic Defence and Security Review, which scrapped four frigates – regarded as the workhorses of the navy.

Committing ships and personnel to the Olympic security effort this summer has compounded the MoD's difficulties.

"Counter-piracy is getting very difficult for the UK," said one senior Whitehall source. "We have two frigates that are supposed to look after contingencies in Falklands, the Gulf and piracy. Fort Victoria is a good platform but we cannot commit frigates to Somalia. They go in and out when they can, but reassurance work in the Gulf is more of a priority now.

"Many of the people who are good at counter-piracy are now involved in the Olympics, so they are not available either, and won't be until the autumn at the earliest."

The scaling back comes at an awkward time for the military mission off the Somali coast. Though the number of successful pirate attacks fell last year, the number of pirates facing prosecution remains extremely low.

In the past four months, dozens of suspected pirates have been set free because arresting countries, including the UK, are reluctant to host prosecutions against them.

The UN has estimated nine out of 10 suspects are being released. One Nato commander told the Guardian he had kept 17 suspected pirates on board his ship for 38 days before being told to let them go in April.

"When I have told them [the pirates] that we are putting them back to shore they are more or less celebrating," said Commander Anders Friis, captain of the Danish ship Absalon. "They are very, very happy."

Friis suggested other nations needed to take more responsibility for the problem. "What is needed from my perspective, but it is at the edge of politics … we have to involve other countries in the region," he said.

Another British naval source added: "For every pirate that goes to legal finish there are three or four that end up being put back ashore."

A legal adviser on board the Absalon said even if he judged a case strong enough to go to court, his recommendations were often turned down.

"This is not because of the evidence package," said Mathais Buck. "But because the national authorities could not find anyone to prosecute them. As soon as the lawyers get involved, the problems start."

The captain of the USS Taylor, an American frigate that is part of Nato's current naval mission, told the Guardian the military could only do so much.

"We are dealing with the symptoms, but if you don't treat the symptoms, they get worse," said Captain Jeremy Hill.

But he admitted that piracy would ultimately only end when the problems were tackled at source. "The significant part of the solution is on land," he said.

The MoD confirmed that none of its frigates were now solely deployed on piracy duties, though it said one could be used for "focused surges".

"The number of successful hijacks and hostages being held is at a three-year low, which is the result of real successes at sea such as the capture and detention of 14 pirates by RFA Fort Victoria in January.

"A Royal Navy frigate supports Nato counter-piracy operations with focused surges of units and it commands the European Union counter-piracy mission.

"The government remains fully committed to helping restore stability in Somalia, and the Royal Navy's activity to deter and disrupt pirates is only a part of the UK's comprehensive approach."

The Foreign Office acknowledged that finding countries in which to prosecute pirates remained a real problem. It said officials were working to "set up a network of regional centres in Kenya, Mauritius, Seychelles, and Tanzania to prosecute suspected Somali pirates who, if convicted, are returned to Somalia to serve their sentences in secure and humane prisons".

A spokesman added: "However, prison capacity remains a key problem in the region. In 2011 the government provided roughly £9m to the UN Office on Drugs and Crime to build regional prison and judicial capacity. The regional transfer agreements coupled with UK support to the UNODC means that we are in a much stronger position to bring Somali pirates to justice."