It took Somali forces more than 30 hours to contain the militants who stormed Mogadishu’s Hayat Hotel on Friday night in an attack that began with loud explosions. The attack is the first major terrorist attack in Mogadishu since Somalia’s new leader, Hassan Sheikh Mohamud, took office in May. The siege ended around midnight, police commissioner Abdi Hassan Hijar told reporters. “During the attack, security forces rescued many civilians trapped in the hotel, including women and children,” he said. Health Minister Dr. Ali Haji Adam reported 21 deaths and 117 injured, with at least 15 in critical condition. He noted that some victims may not have been taken to hospitals. The Islamic extremist group al-Shabaab, which has ties to al-Qaeda, claimed responsibility for the attack, the latest in its frequent attempts to hit places visited by government officials. Al-Shabab opposes the federal government and outside groups that support it. Al-Shabab remains the deadliest Islamic extremist group in Africa and the biggest threat to political stability in the volatile Horn of Africa nation. Police have not yet given a detailed explanation of how the attack unfolded and it remains unclear how many gunmen entered the hotel. Ismail Abdi, the hotel manager, told The Associated Press early Sunday that security forces were still working to clear the area. The sound of gunfire ended at 9 am. Onlookers gathered outside the gates of the badly damaged hotel on Sunday morning, taking in the scene. Somalia’s previous president, Mohamed Abdullahi Mohamed, avoided any major confrontation with al-Shabaab. But Mohammed has said his government will take on the offensive against the group’s thousands of fighters, backed by returning US forces. Al-Shabab accused via its radio station in Andalusia that the hotel attack was in response to Mohamud’s claim that he would wipe the group out of Somalia. UN Secretary-General Antonio Guterres condemned the attack, saying the United Nations was supporting the people of Somalia “in their fight against terrorism and in their journey to peace”. Al-Shabaab has seized even more territory in recent years, taking advantage of rifts among Somalia’s security forces as well as disputes between the seat of government in Mogadishu and regional states. Forced out of Mogadishu in 2011, al-Shabab is slowly making a comeback from the rural areas it retreated to, defying the presence of African Union peacekeepers as well as US drone strikes targeting its fighters. Militants in early May attacked a military base of AU peacekeepers outside Mogadishu, killing several Burundian soldiers. The attack came just days before a presidential vote that returned Mohamed to power five years after he was voted out.