Gunmen wearing suicide vests stormed the main court complex in Mogadishu Sunday, killing at least five people before holing themselves up as Somali and African forces surrounded the building.
Several people were wounded minutes later when a remote-detonated car bomb went off as a Turkish aid convoy drove by near the airport, in some of the worst violence to hit Mogadishu in months.
"So far at least five people, among them civilians, were confirmed dead" in the courthouse attack, Ahmed Abdulkadir, a police officer there, told AFP, adding: "The death toll could be higher since the situation is not under control yet."
There was no claim for the attack but the security services in Mogadishu said it was carried out by the Shebab, an Al Qaeda-linked group that controlled most of the city until it abandoned fixed positions in August 2011.
"Shebab suicide bombers have attacked the court and regional headquarters area. At least one of them detonated himself, leaving several dead," said Abdirahman Mohamed, an intelligence officer in Mogadishu.
A car also exploded opposite the court complex as chaos engulfed the neighbourhood, with survivors and witnesses saying at least three of the attackers blew themselves up.
"There are still several of them fighting the security forces inside the building," Mohamed said.
Moments later, civilians reached by AFP on their mobile phones said they were trapped inside the copmplex as the situation developed into a standoff.
"We are trapped inside the offices and we cannot go outside," Fadumo Ali, a witness inside the office of the regional administration next door to the courthouse, said.
"Some of the terrorists are still inside the court building and they are wearing explosive vests. The building has been surrounded by the Somali troops and AMISOM peacekeepers."
A semblance of normalcy had returned to the war-battered seaside capital since mid-2011, when the Shebab pulled out and started losing most of their strongholds across the country.
A regional military offensive has forced many Shebab forces to retreat to the mountains in northern Somalia but the insurgents have reverted to guerriklla tactics and carried out several bomb attacks in Mogadishu.
"This attack is nothing but a sign of desperation by the terrorists, who've lost all their strongholds and are in complete decline right across Somalia," Somalia's President Hassan Sheikh Mohamud said in a statement.
The courthouse is in the heavily-guarded administrative quarter of the capital and a police officer said Somali and African Union forces had been deployed in an attempt "to restore normalcy".
It is believed that senior judiciary officials, including the judge of the Supreme Court, were in the building when the gunmen stormed it but it was not known if they were among the casualties.
In an almost simultaneous attack near the airport, on the edge of the city, a car parked by the roadside and packed with explosives was detonated.
"They detonated it remotely when a convoy of the Turkish aid organisation was passing by," said Nur Osman, who witnessed the attack from the rooftop of a nearby building.
"I can still see the shell of the burning car. Several people including security guards have been evacuated. I do not know how badly they have been injured," he told AFP.
Turkey has recently taken a leading role in Somalia and is very active in reconstruction and aid projects across the country, which has been left in ruins by two decades of almost uninterrupted conflict.