William Hague today warned more action was needed to tackle the terrorist threat from Somalia as he became the first British Foreign Secretary to visit the strife-torn African nation for 20 years.
Mr Hague said dealing with militant Islamists who have made the country their base "matters a lot" to the security of the United Kingdom.
His arrival in the capital, Mogadishu, marked the start of a major diplomatic push by Britain to help stabilise a country he described as "the world's most failed state".
The Government is hosting an international conference in London on Somalia later this month and Mr Hague said counter-terrorism co-operation would be high on the agenda.
"We need to step this up. We are not complacent about it," he said.
Security in the capital has improved since an offensive last year by a 10,000-strong African Union force in the country (Amisom) drove the jihadists of al Shabaab out of the city.
Nevertheless suicide bombings, improvised explosive devices, and grenade attacks remain regular occurrences while al Shabaab - which has links with al-Qa'ida - still controls much of southern Somalia.
At the same time pirates continue to prey on international shipping passing through Somali waters while the region still has more than a million refugees forced to flee their homes by famine.
The dangers were underlined by the tight security arrangements surrounding Mr Hague's short, 10-minute journey from Amison's base at the airport to the residence of President Sheikh Sharif Sheikh Ahmed.
The Foreign Secretary and his entourage were required to don body armour and helmets and travelled in a small convoy of armoured vehicles manned by Amisom soldiers.
With the director general of MI5 Jonathan Evans having warned in 2010 of the threat posed to the UK by terrorists trained in al Shabaab's camps, Mr Hague said there must be no let up now in the pressure.
"For the security of the UK, it matters a lot for Somalia to become a more stable place," he said.
"Some progress has been made on this, partly because of the progress of the Amisom force.
"One of the objectives of our conference in London is to strengthen counter-terrorism co-operation, to make it easier for countries in this region to disrupt terrorist networks, to disrupt their financing and the movements of potential terrorists."
With the London 2012 Olympics fast approaching Mr Hague said the Government was not aware of any "specific threat" to the Games from Somalia or any other source.
He added however: "Wherever there are such extensive terrorist networks linked to piracy, that is a threat."
His warning of the dangers to the UK were echoed by the Mayor of Mogadishu, Mohamoud Ahmed Nur, who said that with 350,000 Somalis living in the UK, the Government could not afford to ignore the problem.
He said disaffected young British Somalis were already travelling to Somalia to seek terrorist training before returning to Britain with "revenge in their hearts".
"Whatever happens in Mogadishu, in Somalia, will happen in Great Britain. We have interlocking interests," he said.
"There are Somali British fighting alongside al-Qa'ida and al Shabaab. They may go and they may come back.
"Those who leave school with no qualifications, those who go to prison, they say 'Why should I stay in Britain,' so they go and fight. They have revenge in their hearts."
Despite the continuing problems, ministers in London believe the success of the Amisom offensive has opened up a window of opportunity.
At the same time, Mr Hague said the approaching end of the transitional government arrangement in August also pointed to the need for progress.
"I think this will be an important moment in the history of Somalia," he said.
Following his meeting with the president, Mr Hague announced the appointment of Matt Baugh as the first British ambassador to Somalia since 1991 when the country collapsed into chaos and civil war.
He also confirmed the Government's intention to build a new British embassy in Somalia once security conditions allow - although for now Mr Baugh will operate out of the British High Commission in neighbouring Kenya.
Security concerns may also have meant that Mr Hague was unable to travel beyond the presidential complex of Villa Somalia.
But through the window of his armoured vehicle he was at least able to catch a glimpse of the terrible devastation two decades of conflict had inflicted on the city including the wreck of the bombed-out parliament building.
However he also saw what observers say are the first signs of new life emerging from the rubble with businesses opening, building being repaired and rebuilt and people and traffic returning to the streets.