Islamist Shebab rebels carried out a major bomb and armed attack on Somalia's presidential palace, penetrating the heavily fortified complex in the capital Mogadishu before blowing themselves up.
Somalia's internationally backed President Hassan Sheikh Mohamud and Prime Minister Abdiweli Sheikh Ahmed were not inside at the time and were "both safe", officials said, just five months after a similar attack by the Al-Qaeda-linked Shebab.
Security sources said the two men were with guards from the African Union's 22,000-strong AMISOM force and authorities gave no immediate details of casualties from the latest attack.
"There were at least nine attackers, all have been killed, and the situation is under control, the attack is over," security official Abdi Ahmed said.
"There were eight blasts towards the end of the fighting, believed to have been suicide vests. They detonated themselves."
A Shebab spokesman confirmed that the group was behind the attack, and claimed their commandos had managed to seize the president's office inside the presidential compound known as the Villa Somalia.
"Our commandos are inside the so-called presidential office," Shebab spokesman Abdulaziz Abu Musab told AFP. "We are in control of the headquarters of the apostate regime.
"The enemy suffered high casualties during the operation, which is ongoing. The assault is a victory for us since the foreign installed government said that security was beefed up."
The attackers launched a two-pronged attack on the presidential complex, police said, setting off a large bomb at the rear of the compound and then storming in via another entrance. The attack came shortly after the start of Iftar, when Muslims end the day's Ramadan fast.
It was not immediately possible to confirm reports that the embassy of Djibouti, which has troops in Somalia and whose mission is close to the presidential palace, had also come under direct attack.
- US condemnation -
Witnesses said they could hear heavy gunfire and several blasts believed to be from grenades, before the fighting died down around an hour later.
"Bullets are flying around coming from the palace," said Halimo Nure, who lives close to the compound, one of the most heavily defended areas of the city. "There is shooting and gunfire, there are also explosions like they are using grenades."
The UN's top envoy to Somalia, Nicholas Kay, said the attack was "an attempt to rob Somalis of the peaceful state they deserve."
"Terror will not win," he said.
The United States also strongly condemned the attack.
"Incidents such as this further demonstrate that insecurity in Mogadishu persists, including very real threats from Shebab," said State Department spokeswoman Jen Psaki.
"This is why we continue to support the efforts of the Somali National Security Forces and the African Union Mission to Somalia (AMISOM) to expand security and stability in Somalia. These forces stopped today’s attackers and prevented further harm."
- History of attacks -
It appeared to be a repeat of a Shebab assault against the presidential palace in February, when the Islamists, dressed in Somali army uniforms, managed to penetrate the complex with a car bomb before being killed.
In May the Islamist insurgents also launched a similar suicide attack against the national parliament while MPs were in a meeting, killing several guards and staff before AMISOM and Somali government forces restored control.
The attacks have targeted key areas of government, or the security forces, in an apparent bid to discredit claims by the authorities that they are winning the war against the Islamist fighters.
The Shebab commander in Mogadishu, Sheikh Ali Mohamed Hussein, vowed last month that the capital would become the "frontline" for assaults.
The Shebab have also increased their scope of operations since last September, when they launched an attack on Nairobi's Westgate mall in which at least 67 people were killed.
In May the Shebab carried out a restaurant bombing in Djibouti and has in the past attacked Uganda and Ethiopia, countries which also contribute to the AU force in Somalia.
Kenya has also seen a wave of massacres carried out by Islamists near the coastal resort island of Lamu, for which the Shebab has claimed responsibility, as well as a string of bombings in Mombasa and Nairobi.
Hardline Shebab insurgents once controlled most of southern and central Somalia, including large parts of the capital, but were driven out of fixed positions in Mogadishu and Somalia's major towns by the African Union force.
AU troops launched a fresh offensive in March against Shebab bases, and although they seized a series of towns, the insurgents are thought to have fled in advance and suffered few casualties.