Islamist al-Shabab militants have attacked the presidential palace in the Somali capital, Mogadishu, and entered the heavily fortified compound.
An al-Shabab spokesman said fighting was ongoing, but a government official told the BBC the attack was over and the militants had all been killed.
President Hassan Sheikh Mohamud was not at the palace at the time.
The al-Qaeda-aligned al-Shabab group lost control of Mogadishu in 2011, but often carries out attacks in the city.
The group has vowed to step up attacks during the Islamic holy month of Ramadan.
On Saturday, a suicide car bomb exploded near the capital’s parliament building, killing at least four people.
President Mohamud was attending a function at the residence of the UN special envoy to Somalia, near the airport.
A large contingent of the Somali military police accompanied him, leaving the presidential palace, known as Villa Somalia, mainly under the protection of African Union soldiers, he says.
The presidential palace is the seat of government and many top government officials live and work there.
It is not clear if the prime minister and speaker of parliament were in the compound when it was attacked.
“We have entered the so-called presidential palace. We have now captured some parts of the palace and fighting is still going on,” al-Shabab spokesman Sheikh Abdiasis Abu Musab told the Reuters news agency.
The spokesman said that 14 government soldiers had been killed in the attack.
However a government official, who asked not to be named, told the BBC the situation was now under control and that attackers had all been killed.
He declined to comment on the number of casualties.