By Abdi Sheikh and Feisal Omar
MOGADISHU (Reuters) - At least 19 people were killed in the Somali capital on Sunday in bomb attacks carried out by militants linked to al Qaeda and subsequent gun battles with the al Shabaab fighters, breaking a fragile return to peace in Mogadishu.
A bomb exploded outside law courts in the city as gunmen stormed the compound. Security forces then arrived and battled the fighters inside. Later, a bomb exploded near an African Union and Turkish Red Crescent convoy on the way to the airport.
Al Shabaab said it carried out the attacks.
"About seven well-armed men in government uniform entered the court today as soon as a car bomb exploded at the gate. We thought they were government soldiers," said Aden Sabdow, who works at the mayor's office adjacent to the court.
"Armed men entered the court and then we heard a blast. Then they started opening fire. We do not know the number of casualties," said Hussein Ali, who works at the courts.
Somali forces arrived and laid siege to the compound and there was a second blast while the two sides exchanged gunfire. Hours later, the shooting stopped, but government forces said they believed some fighters were still hiding inside.
Reuters reporters counted 16 bodies around the compound, some of them in uniform, some not, but it was not clear how many of them were government soldiers, attackers, or civilians.
Witnesses at the scene said in addition to the car bombs, three of the gunmen who stormed the court also blew themselves up using explosives strapped on their bodies.
Security in the coastal capital has improved greatly since al Shabaab fled the city after an AU and Somali government military offensive in August 2011. Now it's rubble-strewn streets are choked with traffic and constructions sites point to a new confidence as Somalis from abroad and invest in their homeland.
But the threat persists from al Shabaab, which still controls much of the countryside.
"We carried out a superb intense mission in Mogadishu today. We killed 26 people including soldiers and court staff," said al Shabaab spokesman Sheikh Ali Mohamud Rage.
"We assigned five special mujahideen for the court - four of them entered and killed the people inside. The other mujahid with his car bomb exploded when government soldiers gathered at the gate."
Al Shabaab routinely inflates the number of people it kills.
AL SHABAAB STRIKES BACK
Security forces managed to rescue the Supreme Court chairman and other officials, some of whom climbed out of buildings using ladders.
"The supreme court chairman and other judges have now safely arrived at the mayor's office through another door. Many ladders have also been placed on the walls and some staff and civilians and have managed to escape using the ladders," Sabdow said.
Later, a car bomb exploded at a building housing Somali intelligence along the road to the airport as Turkish and African Union (AU) vehicles were passing, police and witnesses said. Government forces then opened fire and blocked the road.
"The car bomb exploded near the gate of a building housing the Somali security. AU and Turkish cars were also passing there. We are still investigating the target and casualties," Qadar Ali, a police officer told Reuters.
Witnesses said three people were killed in the blast.
"I saw three dead people including a man, a woman and a child. The ruined car bomb is in the middle of the road," Hussein Bile, a witness told Reuters.
"The explosion occurred here, the car with the bomb targeted Turkish vehicles driving on the streets and hit the last car on the convoy, two Turkish died while two women passersby were also killed," Abdifatah Canjex, a district police officer, said.
A Turkish official who spoke on condition of anonymity said one of its Red Crescent vehicles was passing at the time of the explosion. A Somali driver was killed and three Turkish passengers were wounded, the official said.
Another Somali police officer said there were Turks among the dead.
Britain warned on April 5 it believed "terrorists are in the final stages of planning attacks in Mogadishu". <ID:
In control of much of the capital Mogadishu between 2009 and 2011, al Shabaab has been forced out of most major cities in central and southern Somalia by African Union peacekeepers.
But the hardline Islamist group has hit back with a series of bomb attacks. In early April, a bomb went off outside the headquarters of Somalia's biggest bank, Dahabshiil's, wounding at least two people hours after al Shabaab ordered the company to cease operations in areas under its control.
"Somalia, is moving and will keep moving forward and will not be prevented to achieve the ultimate noble goal, a peaceful and stable Somalia, by a few desperate terrorists," President Hassan Sheikh Mohamud said in a statement.
Last month, al Shabaab claimed responsibility for suicide car bomb targeting a senior Somali security official which killed at least 10 people in central Mogadishu. The security official survived the attack, the city's deadliest this year.
(Additional reporting by Jonathon Burch in Ankara and Abdi Daqane in Mogadishu; Writing by George Obulutsa; Editing by)