Fighters who have carried out near-daily assaults against the interim government and its Ethiopian allies for the past two months had threatened to attack the AU troops.
The men are thought to be mainly fighters loyal to the Union of Islamic Courts which had gained widespread authority across the country until being routed from the capital in December by the Ethiopian military supporting the interim government.
The AU force is being deployed to help the government of Abdullahi Yusuf, the interim president, extend its shaky authority over the country which has been in a state of conflict since Mohamed Siad Barre, the former president, was overthrown in 1991.
None of the 13 other attempts at government since then has succeeded.
As with a peacekeeping operation in Sudan's Darfur region, the AU faces a shortage of money and equipment.
Nigeria, Ghana, Malawi and Burundi are expected to send troops, but pledges so far make up only about half of the required 8,000 soldiers.
A well-funded US-UN peacekeeping mission left Mogadishu in 1995 after relentless attacks from well-armed Somali fighters.