Al-Shabab and its allies control much of southern Somalia and Mogadishu
Somali militants accused of links to al-Qaeda have banned three United Nations agencies from operating in two southern towns they control.
Members of al-Shabab also raided the offices of the UN Political Office for Somalia, the Development Programme and the Department of Safety and Security.
Al-Shabab, who are fighting the UN-backed interim government, accused the agencies of being enemies of Islam.
A UN official said the raids had halted vital humanitarian work in the country.
The UN brokered the deal which brought President Sheikh Sharif Sheikh Ahmed, a moderate Islamist, to power in January.
Although he has promised to introduce Sharia law, al-Shabab accuses him of being a Western stooge and stages frequent attacks on government targets.
One unnamed UN staff member told Reuters news agency that armed militia had surrounded the compound in Baidoa and taken away three cars.
Another official told AFP news agency that al-Shabab members had "told staff not to worry, nobody will harm them".
Roseanne Charlton, the UN's acting humanitarian co-ordinator for Somalia, told the BBC that crucial radio equipment had been taken from Baidoa.
She said the theft would hold up critical humanitarian work.
After some two decades of conflict in Somalia, almost a third of the population needs food aid, donors say.
AFP reported that offices in the town of Wajid had also been targeted.
Other UN offices in both towns were not affected.
The UN runs its operations largely from neighbouring Kenya.
A statement broadcast on local radio from al-Shabab said the three UN organisations were "working against the benefit of the Somali Muslim population and against the establishment of an Islamic state in Somalia".
Al-Shabab and its allies control much of southern Somalia and swathes of the capital Mogadishu.
The group is currently holding two French security advisors, who were seized by gunmen in Mogadishu last week.