The bomber detonated an explosive vest at the highly guarded compound, but it was not immediately clear if President Sharif Sheikh Ahmed, who was in Ethiopia on Tuesday, was back in the country.
The Al Qaeda-affiliated rebel group Shebab said one of its volunteers had carried out the attack, claiming 16 people had been killed.
"The mujahideen carried out a spectacular martyrdom operation inside the presidential palace of the apostate Somali regime," the group said in a Twitter post.
Police spokesman Abdulahi Hasan Barise said that according to initial reports at least three people had been killed, including the bomber, and that six others had been injured.
The insurgents have been fighting to overthrow the weak Western-backed Somalia government which is propped up in Mogadishu by a 10,000-strong African Union force comprising troops from Djibouti, Burundi and Uganda.