Mogadishu, Somalia (CNN) -- At least 10 heavily armed militants forced their way into a court building Sunday in Mogadishu, Somalia, and launched a deadly attack, according to a local journalist who witnessed the aftermath.
Some of the assailants detonated explosives before others exchanged fire with government security, witnesses said.
Diplomatic sources told CNN that 29 people were killed in the courthouse attack.
At least nine members of the Islamist militant group Al-Shabaab were also killed, the sources said. That group claimed responsibility for the attack.
Nearly 60 people were wounded in the skirmish, the officials said.
"Above all, today's operations ought to drive this unambiguous message home: there is no safe haven for apostates in Mogadishu!" the group said on Twitter, according to a CNN translation.
Somali President Hassan Sheikh Mohamud said called the strike "nothing but a sign of desperation by the terrorists," saying the militants "are in complete decline." The president said the court complex was one of several sites hit.
"We are moving forward, but the enemy of Somalia, the enemy of all mankind, will attempt to set us back and try to prevent us from prospering. I want the terrorist to know that our country, 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," he said.
The regional court was in session at the time of the attack, witnesses said. The building also houses the nation's Supreme Court.
Radio Mogadishu, a state radio service, reported that at least 100 people who were in the building had come out safely.
Somali security officials said two Turkish nationals from a passing aid convoy and two Somali civilians were killed in a car bombing attack near the Mogadishu airport.
Witnesses told CNN there also were fatal bombings at a military intelligence building and a clinic.
Somalia's shaky transitional government, backed by African Union peacekeepers, has been battling Islamist guerrillas for years. The country has lacked an effective central government since 1991, with portions of the Horn of Africa nation left lawless.
CNN's Nima Elbagir in Nairobi, Kenya and Amir Ahmed in Atlanta contributed to this story.