William Hague visits Somalia's Mogadishu
William Hague has called for renewed pressure against Islamist militants during the first visit to Somalia by a British foreign secretary for 20 years.
His arrival in the capital, Mogadishu signals the start of a major diplomatic push to restore stability in Somalia.
The British government is holding a conference in London on 23 February to try to find a political solution, and tackle piracy and extremism.
The first UK envoy for two decades has also been appointed.
Mr Hague said a British embassy would be established in Mogadishu once the security situation allowed, and until then ambassador Matt Baugh would be based in the Kenyan capital, Nairobi.
Suicide bombings and other attacks by Islamist militants make the city one of the most dangerous in the world.
Security was tight for the visit of foreign secretary, who travelled in a fleet of armoured vehicles to meet Somalia's President Sheikh Sharif Ahmed.
After the meeting at the presidential palace in Mogadishu, Mr Hague described Somalia as "the world's most failed state".
He praised African Union troops for forcing al-Shabab militants out of the city.
But he warned that much of the south remained in the hands of the militants, saying: "We need to step this up."
The country has been torn apart by two decades of war, beset by drought and famine, and is home to a piracy industry that threatens shipping across the Indian Ocean.
But analysts say the military fortunes of al-Shabab have dramatically worsened in the last year.
Neighbouring Ethiopia and Kenya also have forces in Somalia - and have made advances on al-Shabab in the south and the west.
Tackling root causes
Mr Hague's visit follows another sign of growing international confidence in the improving security situation, at least in Mogadishu - the UN special envoy to Somalia has moved his office back from neighbouring Kenya to the city after an absence of 17 years.
Turkish Prime Minister Recep Tayyip Erdogan visited in August, and UN chief Ban Ki-Moon in December, the first visit by a UN secretary general in 18 years.
UK International Development Secretary Andrew Mitchell visited Puntland, northern Somalia, over the weekend - after an August visit to Mogadishu.
Correspondents say Britain now appears to driving a new international push to tackle the roots causes of Somalia's insecurity and conflict.
Representatives from more than 40 nations have been invited to the London conference on Somalia later this month.
"The conference will seek to generate a more effective and concerted international approach outside Somalia that addresses the root causes of the conflict; and a new political process inside Somalia that meets the needs of all Somalis," Mr Hague said in a statement.
In 2010, MI5 director-general Jonathan Evans warned that it was "only a matter of time" before militants trained in Somali camps inspired acts of violence on the streets of the UK.