A remote-controlled land mine hidden in a pile of garbage exploded as a convoy of African Union peacekeepers drove by.
There were no injuries, said Col. Jack Mukaze, a member of the AU force, which is comprised entirely of Ugandan troops.
"No one was killed and no one was injured," he told The Associated Press. "Our troops survived."
Mogadishu has seen little peace since government troops backed by Ethiopian forces drove an Islamic movement out of the city in December. Roadside bombs, attacks on government installations, assassination attempts and gunbattles have become common, and civilians are caught in the crossfire.
Uganda has about 1,700 troops in Somalia, officially as the vanguard of a larger AU peacekeeping force, though so far no other countries have sent reinforcements.
Somalia has been mired in chaos since 1991, when warlords overthrew dictator Mohamed Siad Barre and then turned against one another, defending clan fiefdoms. The government was formed in 2004 with the help of the United Nations, but has struggled to assert any real control.
The ousted Islamic movement ruled Mogadishu and much of southern Somali for six months last year, during which they sought to impose an Islamic state.
More than 3,500 people were detained during unprecedented mass protests that swept across all of Russia in support of Alexey Navalny on January 23