At least 28 people have been killed and dozens wounded in a coordinated gun-and-bomb attack carried out by al-Shabab at a popular hotel in Somalia's capital, Mogadishu, according to officials.

The assault on Wednesday morning began when attackers rammed an explosives-packed car into the gate of Dayah Hotel, which is near Somalia's parliament in central Mogadishu, and then stormed inside exchanging gunfire with security guards.

A second massive car bomb blast went off after ambulances and journalists had arrived at the scene, leaving at least four reporters wounded, according to AFP news agency.

"We have confirmed 28 people died and 43 others were injured in the two blasts at the hotel," Abdikadir Abdirahman, director of the capital's ambulance services, told Reuters news agency.

Security Minister Abdirizak Umar told reporters at the scene that 51 people were wounded in the two blasts at the hotel.

Al Jazeera's Catherine Soi, reporting from Nairobi in neighbouring Kenya, said a freelance journalist working for Al Jazeera Arabic was among those wounded.

OPINION: US policies do more harm than good in Somalia

Colonel Abdiqadir Hussein, a police officer, told Reuters that security forces eventually managed to secure the building.

"We have rescued the people and concluded the operation at Dayah Hotel."

Witnesses said the powerful explosions caused extensive damage in the area near the hotel, shattering dozens of windows and damaging parked cars.

"All the neighbouring houses have been destroyed," Yusuf Hassan, editor of Somali newspaper Haqiqa Times, told Al Jazeera from the scene.

"I see people crying because they have lost their relatives," he added.

"It is really a big tragedy."

Al-Shabab claimed responsibility for the attack, according to a report by Andalus radio, which is linked to the armed group.

"Well-armed mujahideen [fighters] attacked the hotel and now they are fighting inside the hotel," the report said.

Dozens of people, including members of Somalia's parliament, were thought to have been in the hotel at the time of the attack, Captain Mohamed Hussein told The Associated Press news agency.

The hotel is popular with politicians, government officials and entrepreneurs.

Al-Shabab has carried out a series of deadly attacks in Somalia to try to topple the country's western-backed government.

In June, the group claimed responsibility for an attack on the Nasa Hablod hotel, which killed at least 15 people.