The UK has established a small military presence in Somalia, the British Ministry of Defence has confirmed.
A team of 10 military advisers is based at the headquarters of the African Union force in the capital, Mogadishu.
They do not have a combat role; their job is to help the AU with planning, communications and medical support.
But a BBC correspondent says some of the advisers have been seen in Afgoye, a strategic town west of the capital recently taken from Islamist militants.
The al-Shabab group, which joined al-Qaeda earlier this year, still controls many rural areas in southern and central Somalia but is under pressure on several fronts.
The country has been without a functioning central authority since 1991 and has been wracked by fighting ever since – a situation that has allowed piracy and lawlessness to flourish.
“We have sent a small team of advisers to assist the AU peacekeeping mission. They do not have a combat role,” an MoD spokesman said in a statement.
BBC world affairs correspondent Peter Biles says the confirmation of a British military presence in Somalia comes at a key moment in the efforts towards a political transition.
The UN-backed interim government is supposed to hand over to a new administration by 20 August when a new president and parliament will be elected.
Our correspondent says it is hoped that this will end the corruption and misappropriation of funds that have tarnished the reputation of the current Somali authorities.
Ethiopian troops, pro-government militias and the African Union force – which has US and European funding and was boosted earlier this year to nearly 18,000 – have helped the transitional government recently expand its control outside Mogadishu.
In the last few months, the militants have lost several key positions, including Afgoye, Baidoa in central Somalia and the southern town of Afmadow.