Islamist militants from the al-Shabab movement have attacked the Somali parliament in Mogadishu, leaving at least 10 people dead.
Explosions and gunfire were heard and witnesses reported seeing bodies.
Somali police were joined by African Union troops as they engaged the attackers.
Al-Shabab, which is linked to al-Qaeda, once controlled large areas of Somalia but was pushed out of major cities in 2011 and 2012.
However, it is still able to mount complex attacks. It has frequently targeted the UN-backed parliament.
A car bomb exploded outside the gates of parliament shortly before midday local time (09:00 GMT), followed by more blasts and bursts of gunfire.
The attackers then stormed the front of the parliament building as security forces fired back.
“Fighting is going on inside the parliament building and we are fighting rebels inside the building but we evacuated members of parliament,” Col Mahamed Dahir said.
At least four police officers and several militants were reported killed. Eyewitnesses saw a number of bodies in military fatigues but could not confirm whether they were members of the security forces.
Two MPs were reportedly wounded in the attack as they were taken out of the back of the building.
“The enemy can now access everywhere,” MP Mohamed Nor told Associated Press, criticising the army’s failure to protect parliament.
An al-Shabab spokesman told the AFP news agency: “The so-called Somali parliament is a military zone. Our fighters are there to carry out a holy operation.”
African Union (AU) troops from the 22,000-strong Amisom security force joined the Somali army in fighting the insurgents around parliament, an Amisom spokesman said.
The UN envoy to Somalia Nicholas Kay said he was “horrified” by the attack and paid tribute to the response of Somali and African Union forces.
Somalia has experienced almost constant conflict since its government collapsed in 1991.
With Mogadishu and other towns now under government control, basic services such as street lighting and rubbish collection have now resumed.
Many Somalis have returned from exile, bringing their money and skills with them.
The parliament in Mogadishu – which operated as a transitional assembly from 2004 to 2012 – has been attacked several times, including in 2009 and 2010.
Last month, a Somali parliamentarian was blown up and another shot dead in separate attacks.
In February, al-Shabab militants attacked the presidential palace in Mogadishu, leaving at least 16 people dead.
Al-Shabab, whose name means “The Youth” in Arabic, advocates the strict Saudi-inspired Wahhabi version of Islam.