Residents survey remains after the Friday bombings in Mogadishu.
CNN  — 

Twin car bombings and a gun battle in the heart of Somalia’s capital left dozens dead and scores wounded, authorities said Saturday.

Nearly 40 people died in the violence, which broke out in Mogadishu on Friday night, medical sources said.

Among the dead were five militants, Somali Security Minister Mohamed Abukar Islow said. At least one soldier died as well.

The Somali terror network Al Shabaab issued a claim of responsibility for the attack on its radio station. The attack took place a day after a government alert was issued about an explosives-laden vehicles in the capital.

Hours-long unrest

Mogadishu Police Capt. Liban Abdi told CNN that the attack began when a car packed with explosives was detonated at a main security checkpoint around Villa Somalia, the country’s presidential palace.

After the first car bomb, armed militants in a vehicle sped toward the palace and encountered heavy resistance from the presidential guards at a second checkpoint and a gunfight broke out there.

“A few minutes later, the second car bomb went off near a newly opened hotel,” Abdi said. “Security forces battled the attackers trying to storm the presidential palace.”

Police officer Ahmed Hassan said militants who stormed the palace were wearing Somali police uniforms. He said the unrest lasted nearly three hours.

Al Shabaab, an al Qaeda-linked terror group, has carried out several deadly car bomb attacks in the city.

CNN’s Hande Atay Alam contributed to this report.