Al Shabaab, the Islamist rebel group that professes loyalty to al Qaeada, said it had carried out the attack and would keep targeting Abdi Hassan Awale until they kill him.
"Our bomber targeted Abdi Hassan. He is a great infidel. He used to be a minister for Sharif's government" al Shabaab spokesman Abdiasis Abu Musab said.
"His bodyguards died in the attack. He escaped today but we shall not stop targeting till we get rid of him," he added.
Awale controlled a section of the capital Mogadishu before he was defeated by forces of the Islamic Courts Union in 2006. He later served as a minister for minerals and water in President Sheikh Sharif Ahmed's government.
One witness said the bomber shot dead Awale's armed driver at the entrance to the compound in the town of Galkayo before detonating his explosives when a bodyguard jumped on him.
Colonel Mohamed Hussein told Reuters that the dead men were policemen.
"The bomber killed the driver with a pistol and the guard with the blast," he said.
Shopkeeper Farah Elmi, who witnessed the attack, confirmed the sequence of events. The bomber's dismembered corpse was visible inside the compound, he said.
Awale, who hails from Galmudug, had been mediating in a row between the regional president and local lawmakers, according to Hussein.
The town of Galkayo straddles Galmudug and the semi-autonomous Puntland region more than 500 km (320 miles) north of Mogadishu in central Somalia.
Earlier this month a local militia abducted a foreign journalist holding dual U.S.-German citizenship from the town.
(Reporting by Abdi Sheikh and Feisal Omar; Writing by Duncan Miriri and Richard Lough; Editing by Angus MacSwan)