He said: "We don't how the suicide bomber managed to pass through undetected ... The wounded cannot be counted," the officer told Reuters.
A security source close to the prime minister said seven people were killed, including five soldiers guarding the residence. The blast flattened other buildings in the area.
Gedi's interim administration is struggling to impose its authority on the anarchic Horn of Africa nation.
A witness at the scene said an Islamic school was among the buildings damaged in the explosion. "No one knows what happened to the children inside," he said.
Ankunda said that a number of people were killed and others wounded.
He said African Union troops are busy evacuating the wounded.
Ankunda said that within minutes of the explosion, peacekeepers sealed off the area around Gedi's house and took charge of security.
Qasaye Mohamed Ali, who lives in the neighbourhood, said he was standing near the prime minister's house when he saw the car force its way through a roadblock.
Guards outside opened fire and then the car rammed into a wall and exploded, he said.