The explosion late Wednesday, in the southern town of Baidoa, targeted a base manned mostly by Ethiopian troops, who are here protecting Somalia's weak government. Prime Minister Ali Mohamed Gedi was not hurt.
"The explosion was so deafening and strong it rocked our entire hotel compound," said Mohamed Abdi Haji, a member of Gedi's staff. The blast killed two soldiers and the bomber, witnesses said.
Details were sketchy because the area has been sealed off since the blast. The government has not commented.
Somalia's U.N.-backed government has been struggling to assert authority since it chased a powerful Islamic alliance out of power in December with the help of Ethiopian allies. The Islamic fighters vowed to fight an Iraq-style insurgency against the government and the Ethiopians, and the fighting has claimed thousands of lives this year.
Gedi has been meeting supporters in Baidoa, a provincial town some 150 miles (240 kilometers) from Mogadishu, amid reports that President Abdullahi Yusuf wants to push through a no-confidence vote this week and form a new government.
Somalia has not had a functioning government since 1991, when a group of powerful clan leaders overthrew dictator Mohamed Siad Barre and then turned on each other. The arid Horn of Africa nation is deeply impoverished and split by clan rivalries.