A car bomb at a marketplace in Somalia's capital has killed at least 34 people and injured more than 50 others, said a local Somali official.

The blast from the car parked near a restaurant went off at a busy time when shoppers and traders were gathered inside the market, said district commissioner Ahmed Abdulle.

Mohamed Haji, a butcher who suffered shrapnel wounds, pointed at a clothes shop devastated by the blast. "Someone had parked the car here and left before it was detonated," he said. Pieces of wood and metal sheets on the ground were all that was left of the shop.

Women sobbed and screamed outside the market as rescue workers transported bodies and wounded victims into ambulances.

"It's a painful carnage." said Ali Mire, a government soldier who was helping a friend with multiple shrapnel wounds

The powerful explosion was the first major attack since Somalia's new president was elected on February 8.

Although no group has yet claimed responsibility, it bears the hallmarks of Somalia's Islamic extremists rebels, al-Shabab.

In a Twitter post, President Mohamed Abdullahi Mohamed condemned the blast, saying that it shows the "cruelty" of al-Shabab.

A few hours before the blast, al-Shabab denounced the new president as an "apostate" and vowed to continue fighting against his government.

Italian Foreign Minister Angelino Alfano, in a statement condemning the attack, said that "Italy remains solidly on Somalia's side in the process of the country's stabilisation".

He added that "together we will act so that the terrorists don't succeed in stopping the path of peace and reconciliation that is under way."