Rescuers had rushed to the scene of the attack in Mogadishu. / Photo: AFP

Somalia's Al Shabab militant group has attacked a beachside hotel in the capital Mogadishu and security forces are responding at the site as some people remain trapped inside, witnesses and state media said.

The Somali National News Agency reported on Friday that "many civilians" have been rescued from the Pearl Beach hotel as fighting continues on Friday night.

There was no immediate word on casualties.

The Pearl Beach hotel is down the street from the Turkish Embassy and is popular with government officials.

Witness Hassan Abdirahman told The Associated Press that he was in the restaurant at the time.

"I heard the sound of gunshots which came from the beach direction and followed by the huge sound of an explosion."

He said that he escaped and saw damaged vehicles along the street.

Another witness Mulki Osman said he and his friends "instantly fled for cover" in the restaurant when they heard explosions and gunfire shortly before 8 pm [local time].

"Some of my friends are still stuck inside the hotel, but the security officers managed to rescue me. I hope they stay safe," he said.

Lido Beach is one of Mogadishu's most popular areas and is busy on Friday nights as Somalis enjoy the weekend by visiting local coffee shops and ice cream parlours.

Al Qaeda's East Africa affiliate, Al Shabab, has claimed responsibility for the attack.

The Somalia-based armed group is known for carrying out attacks on hotels and other high-profile locations in Mogadishu, usually starting with a suicide bombing.

Mortar explosion

In a separate incident earlier, a mortar shell explosion near Qoryoley town in Somalia's Lower Shabelle region has killed about 27 individuals, mainly children, and injured 53 on Friday, according to the state news agency.

The children were ''playing with a mortar shell that did not go off. It exploded on them,'' Abdi Ahmed, deputy district commissioner of Qoryoley told reporters earlier.

Residents said that the unexploded shells, which were being played with by the children, were used by the warring factions in Somalia.

The deputy district commissioner appealed to the government and aid agencies ''to clear mines and shells from the area." He described the deadly incident as a ''disaster.''

TRT Afrika and agencies