Updated

An overnight attack and siege by al-Shabab extremists on a popular restaurant in Somalia’s capital has killed at least 31, police said.

Security forces in Mogadishu ended the siege at Pizza House restaurant, a popular eatery frequented by the city’s elite, Thursday morning after snipers fired on the attackers.

55db14ba-Somalia

A mother whose daughter was shot in the head by attackers during a militant attack on a restaurant, grieves in Mogadishu, Somalia Thursday, June 15, 2017. (AP Photo/Farah Abdi Warsameh)

Senior Somali police office Capt. Mohamed Hussein said many of the attack’s victims were killed at point-blank range after the attackers hunted them down.

The attack began Wednesday evening after a car bomb exploded at the gate to the restaurant and then gunmen posing as military forces stormed into the establishment.

Al-Shabab, a Somalia-based extremist group that often targets popular areas in the country’s capital, claimed responsibility as the restaurant was under siege.

Somalia

Somalis gather outside a destroyed building near a restaurant that was the scene of a car bomb blast and gun battle in Mogadishu, Somalia Thursday, June 15, 2017. (AP Photo/Farah Abdi Warsameh)

Soldiers surrounded the restaurant building and used guns mounted on the backs of vehicles to neutralize the militants. Troops entered the ground floor while the insurgent snipers held positions upstairs.

All five attackers were killed and after dawn the soldiers secured the building, said Hussein. The troops' efforts to take control of the restaurant were slowed by the darkness of night, forcing them to wait until morning, said Hussein.

Survivors said they hid under tables and curtains as attackers continued firing in the restaurant and hunted for patrons. Attackers moved from room to room, looking for people, said a survivor.

d49bb3fb-Somalia

Somali men carry away the body of a civilian who was killed in a militant attack on a restaurant in Mogadishu, Somalia Thursday, June 15, 2017. (AP Photo/Farah Abdi Warsameh)

"I never thought I would have the chance to see the sun again. They were killing people on sight," Saida Hussein, a university student, told The Associated Press. She said she survived the attack by hiding behind a large table downstairs.

Another survivor, Aden Karie, was wounded by an attacker who spotted him moving behind a curtain in the dark room.

"He shot at me twice and one bullet struck me on the leg," said Karie as he was taken to an awaiting ambulance.

The roofs were blown off the restaurant and nearby buildings from the powerful blasts.

The bodies of five girls thought to have been killed by the militants were found in the restaurant, said police. Inside the building, the body of a Syrian man who worked as a chef at restaurant lay near the rubble of a blood-spattered and bullet-marked wall.

The Somalia-based al-Shabab often targets high-profile areas of Mogadishu, including hotels, military checkpoints and areas near the presidential palace. It has vowed to step up attacks after the recently elected government launched a new military offensive against it.

d50a9f9f-somalia

Somalis walk near destroyed vehicles at the scene of a car bomb blast and gun battle targeting a restaurant in Mogadishu, Somalia Thursday, June 15, 2017. (AP Photo/Farah Abdi Warsameh)

Al-Shabab last year became the deadliest Islamic extremist group in Africa, with more than 4,200 people killed in 2016, according to the Washington-based Africa Center for Strategic Studies.

The extremist group also faces a new military push from the United States after President Donald Trump approved expanded operations, including airstrikes, against al-Shabab. On Sunday, the U.S. military in Africa said it carried out an airstrike in southern Somalia that killed eight Islamic extremists at a rebel command and logistics camp.

Somalia President Mohamed Abdullahi Mohamed confirmed that airstrike and said such attacks would disrupt the group's ability to conduct new attacks.

The Associated Press contributed to this report.