Uganda's President Yoweri Museveni has paid a surprise visit to Somalia's war-ravaged capital.

A spokesman for the African Union peacekeepers, Barigye Bahoku, says that Museveni's more than 4-hour visit on Sunday was meant to show his solidarity with the war-battered Somali people.

He says Museveni met with the Somali president, the prime minister, and peacekeeping commanders and soldiers before he left the country. Uganda has contributed the bulk of the 7,000-strong African Union force that is keeping the country's weak government alive.

Museveni is a strong supporter of an African intervention to defeat insurgents who confined the U.N-backed government into a few blocks of the capital, Mogadishu.

Bahoku says this was Museveni's second visit to Somalia since he took power in 1986.