With ISIS largely defeated in Iraq and Syria, the fight against Islamist terrorism is shifting to Africa. Here's everything you need to know:

Why Africa?

Widespread corruption, poor governance, and large numbers of impoverished young men disillusioned with society have made many parts of Africa fertile breeding grounds for jihadism. The al Qaeda affiliate al-Shabab has terrorized Somalia and neighboring Kenya for more than a decade; Boko Haram began trying to overthrow the Nigerian government and set up its own small Islamic state back in 2002. In recent years, the African terrorist groups have expanded and become more aggressive. IHS Jane's Terrorism and Insurgency Centre recorded 171 Islamist militant attacks in Africa in 2009, resulting in 541 fatalities; in 2015, 738 attacks left 4,600 dead. ISIS's defeat in the Middle East last year exacerbated the problem, as thousands of African jihadists started returning home. Tunisia alone accounted for up to 6,500 of the Sunni terrorist group's foreign fighters — more than any other nation in the world. "The more we succeed in the Middle East," says Sen. Thom Tillis (R-N.C.), "the more we are going to see the snakes run to Africa."

Where are ISIS militants going?

Their main stronghold is Libya, which remains embroiled in a chaotic civil war. The terror group seized the coastal city of Sirte in 2015 — its only major outpost outside Syria and Iraq. They were driven out the following year, by militias backed by U.S. airstrikes, but have since regrouped in remote rural areas. ISIS's other North African hub is Egypt's largely lawless Sinai Peninsula. An ISIS affiliate called Sinai Province has claimed credit for 800 attacks in the region since 2013 and was widely blamed for the massacre at a Sufi mosque in November, in which more than 300 worshippers were killed. Mokhtar Awad, a research fellow in George Washington University's Program on Extremism, says ISIS is trying to inflame sectarian strife in Egypt in the hope it'll lead to "the country's unraveling."

Is al Qaeda still a force?

Increasingly so. While the world's attention has been on ISIS, al Qaeda has been seeking to make a comeback, and its leaders are grooming Osama bin Laden's favorite son, Hamza, for a prominent role as an inspirational leader. The terror group's most prominent African affiliate is al-Shabab, the former radical youth wing of the Islamist organization that used to control Somali's capital, Mogadishu. Al-Shabab carried out the 2013 attack on Nairobi's Westgate Mall and the 2015 massacre at Kenya's Garissa University; it was also blamed for the truck bomb in Mogadishu last October that killed more than 350 people. The group, which enforces a strict Wahhabi version of Islam, no longer controls any major towns or cities — it was ousted from Mogadishu in 2011 by an African Union–led offensive — but still has a significant presence in southern rural areas. Al Qaeda in the Islamic Maghreb, which mainly operates in Algeria and Mali, is the group's most profitable branch: Since 2003, it has made $100 million through kidnapping, drug smuggling, and extortion.

What is the U.S. doing?

The Pentagon has about 6,000 troops engaged in security and counterterrorism missions in Africa. Two-thirds are based in Djibouti, home of the continent's only official U.S. military base; another 800 are in Niger, 400 more are in Somalia, and the rest are spread out across 47 other countries. These numbers have risen significantly in recent years. In 2008, U.S. troops carried out 172 missions, training exercises, or other activities in Africa; last year, they were involved in 3,500. At least 1,700 of the 6,000-strong deployment are special forces, whose official role is to "advise and assist" — train local soldiers and offer them battlefield guidance. But they take part in a broad range of missions, including retaking enemy territory and capturing terrorist leaders. The Pentagon is also increasing its use of drones for surveillance and for targeting individuals and training camps with airstrikes. The U.S. conducted at least 30 airstrikes in Somalia in 2017, compared with 34 over the previous eight years.

What's the long-term strategy?

The Pentagon's primary aim is to prevent an Islamist group from taking control of large swaths of territory, as ISIS did in Iraq and Syria. But this strategy carries risks. Local armies struggle to retain control of areas they recapture from militants. Drone strikes inevitably lead to civilian casualties, which can alienate local populations and serve as a recruiting tool for terrorist groups. Above all, there are fears on both sides of the Atlantic that the U.S. could become bogged down in yet another long-term foreign conflict. "African governments want a small U.S. footprint," said Brig. Gen. Donald Bolduc, then head of U.S. Special Operations Command Africa, last year. "They watch what we've done in other places, and it scares the hell out of them. Quite frankly, it scares the hell out of me too. [You] end up in a much bigger fight than you'd prefer."

A deadly ambush in Niger

The U.S. military's growing presence in Africa was thrust into the spotlight in October, when four special forces soldiers died in an ambush in Niger. Their 12-man team, which was accompanying 30 Nigerien soldiers on a reconnaissance mission, came under heavy attack from about 50 ISIS-affiliated militants armed with rocket-propelled grenades, mortars, and heavy machine guns. The American soldiers fought back for an hour before calling in air support; French jets and helicopters arrived an hour after that. The bodies of three of the fallen soldiers were recovered that day. But Sgt. La David Johnson's corpse wasn't found until 48 hours later, reportedly a mile from the ambush site; more of his remains were discovered a month after that. One villager said his hands were bound and that he had a large impact wound on the back of his head, suggesting he'd been captured, beaten, and executed. A Pentagon investigation due to be released this month, however, reportedly will conclude that Johnson died in a hail of gunfire. The investigation will also examine why U.S. troops were caught unawares by the terrorists, with little available support.