MOGADISHU - Two car bombings killed 38 people in the Somali capital Mogadishu on Friday, the city's main ambulance service told AFP on Saturday.

"We have seen at least 38 people dead," said Abdukadir Abdurahman Aden of the Aamin Ambulance of the bombings that targeted the presidential palace and a hotel.

The first blast, followed by gunfire, occurred at a security checkpoint close to Villa Somalia, the name for the seat of government, while a second followed soon after at a hotel, according to police.

The Shabaab militant group claimed the attacks in a statement posted online, saying it was targeting the government and security services.

The blasts follow weeks of relative calm in Mogadishu. According to officials, the main attack involved the use of a vehicle loaded with explosives attempting to breach a checkpoint leading to the presidential palace, but security forces prevented the assault.

"The security forces foiled the intent of the terrorists. They were aiming for key targets but they could not even go closer, there were five of them killed by the security force," said Abdulahi Ahmed, a security officer.

The Shabaab is fighting to overthrow Somalia's internationally-backed government. In October it carried out its deadliest-ever bombing, killing over 500 people.

In the wake of that attack Somalia's government declared a fresh offensive against the group and US drone strikes have increased in frequency.

While the militant group was pushed out of the capital in 2011 by an African Union force it continues to control large parts of the countryside and launches regular attacks on government, military and civilian targets.