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.
The BBC’s Mohammed Moalimu in Mogadishu says 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.
‘Bullets flying around’
A security official told the AFP news agency that there were at least nine attackers involved in the raid and all had been killed.
The raid is believed to have started with a car bomb at a barrier near the entrance to the compound, after which the militants attacked from two directions, he says.
Halimo Nure, a local resident, told AFP that bullets were “flying around”.
“There is shooting and gunfire, there are also explosions like they are using grenades.”
Al-Shabab militants staged a similar attack on Villa Somalia in February when a car bomb exploded at the gate of the presidential palace, followed by a fierce gun battle inside.
A high-level meeting on how to beef up security in the capital was held at parliament on Monday night, a statement from the prime minister’s office said.
Despite losing Mogadishu and other key cities over the last three years, al-Shabab still controls many smaller towns and rural areas of the country.
Some 22,000 African Union troops are helping the UN-backed government battle al-Shabab, which wants to create an Islamic state.