A suicide bomber detonated an explosives-laden vehicle at the gate of a hotel in Somalia's capital, Mogadishu, which was followed by a second explosion with attackers fighting their way inside the building.

Armed group al-Shabab claimed responsibility for Saturday's attack on the Nasa Hablod hotel in a statement distributed through social networks online.

Police in Somalia said the hotel siege ended late on Saturday, leaving at least 15 people dead.

"The special security forces have ended the siege after killing three attackers inside the hotel. Eleven civilians, two of them doctors, were killed in the attack," Abdi Kamil Shukri, a security ministry spokesman, told reporters.

Journalist Abdirizak Tuuryare told Al Jazeera, quoting police sources, said that "at least 15 people have been killed and 20 more wounded in the attack".

Burci Mohamed Hamza, minister of state for environment, was at the hotel during the attack.

"There are conflicting reports about Burci Mohamed Hamza," Tuuryare said. "Some say he [was] rescued from the hotel, while others say he is dead."

Police captain Ali Ahmed said security forces battled the attackers who took positions inside the hotel near Mogadishu's busy KM-4 junction.

A security official, who asked not to be named, told the DPA news agency that the attack was believed to had been carried out by three to four people.

READ MORE: Somalia in a Snapchat, more than just violence

A witness to the attack, Ali Mohamud, said the attackers randomly shot at guests at the hotel.

"They were shooting at everyone they could see. I escaped through the back door," he said.

Captain Mohamed Hussein said some attackers had moved to the second floor and were using machine guns to resist security forces. Hussein said security forces killed two of the attackers.

He also told the AP news agency that he saw four bodies, thought to be civilians, lying outside the hotel.

READ MORE: Al-Shabab confirms death of Garissa attack leader

Yusuf Ali, an ambulance driver, said he had evacuated 11 people injured in the attack to hospitals.

"Most of them were wounded in crossfire," he said.

Muslims in Somalia and around the world are observing Ramadan. In previous years, al-Shabab has intensified attacks during the fasting month, often picking targets where people gather just before or after breaking the fast.

At least 16 people were killed and 55 more wounded in a car bomb and gun attack on Hotel Ambassador in the centre of Mogadishu on June 1, in an attack claimed by al-Shabab.

In February, at least nine people were killed when al-Shabab fighters set off a car bomb at the gate of a popular park near a hotel in the capital.

In January, another attack on a beach-front restaurant killed at least 17 people.

Loss of strongholds

Al-Shabab was pushed out of Mogadishu by the African Union peacekeeping force (AMISOM) in 2011.

Last year, it was turfed out from strongholds elsewhere in the south by AMISOM and the Somali National Army.

However, it has continued launching frequent attacks aimed at overthrowing the government.

The group has also been behind deadly attacks in Kenya and Uganda.