NAIROBI, Kenya — A large explosion outside a school in Somalia’s capital on Thursday killed at least eight people and injured 17 others, the police said. It was the latest in a series of deadly attacks as Somalia experiences a tense election period and an enormous humanitarian crisis.A vehicle packed with explosives detonated around 7:30 a.m., targeting a convoy belonging to a security firm that guards United Nations staff, according to Abdifatah Aden Hassan, a police spokesman. No U.N. staff members were injured in the blast, he said.Somali Memo, a news website affiliated with the Al Qaeda-linked extremist group Al Shabab, said the group took responsibility for the attack, which occurred on a key road in the northwestern Hodan district of the capital, Mogadishu. The district is home to many schools, restaurants and the residency of a former president.At least 13 students from one of those schools, Mocaasir, were injured in the explosion. Photos and videos from the scene showed mangled school buses and heavily damaged classrooms.“If schools and places of learning are not exempt from targets, then this is a real tragedy,” said Abdulkadir Adan, founder of Aamin Ambulance, a free ambulance service that was among the first to respond to the scene.“The students and teachers now face not just physical injuries, but also psychological trauma,” he added.The Shabab militant group has stepped up its attacks in recent weeks, carrying out suicide bombings, ambushes and assassinations targeting journalists, government officials, the police and foreign peacekeeping forces in Somalia.At least two people were killed in early November in Mogadishu when a suicide bomber targeted a military convoy belonging to the African Union Mission in Somalia (AMISOM). Last week, a suicide bombing killed the director of the government-owned Radio Mogadishu, Abdiaziz Mohamud Guled, whom the militant group said it had been “hunting” for a long time.Last week, the head of the African Union mission, Francisco Caetano Jose Madeira, told the U.N. Security Council that the Shabab had increased attacks on election centers and had “increased public execution of individuals working with Somali security forces and AMISOM personnel.”Authorities and analysts say the armed group is exploiting the numerous economic, political and security challenges facing Somalia. A worsening drought is now affecting about 2.6 million people in 66 out of the country’s 74 districts, according to the United Nations. On Tuesday, Somalia’s prime minister, Mohamed Hussein Roble, declared a state of emergency and appealed to the international community for increased humanitarian assistance.Somalia, in the Horn of Africa, has also been hit by a widespread infestation of desert locusts and the continuing effects of the coronavirus pandemic.Additionally, political leaders continue to wrangle over a drawn-out, heavily contested election. A general election scheduled for earlier this year was delayed after President Mohamed Abdullahi Mohamed moved to extend his rule, in what opponents called a power grab. As voting for lawmakers got underway in recent weeks, many observers have pointed to accusations of vote-buying and manipulation in the process.Many Somalis are also worried about the possible exit of the African Union peacekeeping force, whose mandate expires on Dec. 31. While the mission is expected to continue in some form, a significant reduction of military forces, coming after the withdrawal of U.S. troops early this year, could see the Shabab take over the country, Somali officials and security analysts say. Despite years of foreign funding and training, experts believe that Somalia’s own security forces are not fully capable of stabilizing the country or protecting its people.“Somalia is at a delicate moment right now,” said Omar S. Mahmood, the senior Somalia analyst with the International Crisis Group.“Al Shabaab has always been opportunistic with its violence, especially when political actors are either distracted or consumed by internal squabbles,” he said. “In this sense, it is an opportune time for the movement to increase the tempo of its attacks, especially in Mogadishu.”Hussein Mohamed contributed reporting from Mogadishu, Somalia.