DAKAR, Senegal — The Islamic State has asserted responsibility for an attack that killed 30 soldiers this week in the West African nation of Mali, where extremists are gaining ground in their bloody pursuit to seize territory.

In a statement late Wednesday, the group’s self-described West Africa arm said it also wounded 30 soldiers in the attack while mentioning no deaths among its fighters.

The Malian army, which routinely tangles with extremists in the country’s restive north, said Tuesday that 17 militants were killed in the fight at Tabankort in the Gao region, which borders Burkina Faso and Niger.

U.S. officials say the Sahel region, which lies south of the Sahara Desert, threatens to become a safe haven for terrorists to plot and carry out attacks worldwide. Mali, which is about twice the size of Texas, is a particularly troubling hot spot.

“The rapidly spreading instability in the Sahel threatens U.S. national security and undermines our diplomatic goals,” Whitney Baird, deputy assistant secretary of state for West Africa and security affairs, said at a congressional hearing this month.

“It enables the spread of terrorism, stifles economic growth and thwarts democratic institutions,” she said.

More than 100 soldiers have died in Mali since October in near-weekly clashes as the resource-strapped country tries to shake off a scourge that took root after the Libyan government collapsed in 2011.

Heavily armed mercenaries once employed by Libyan leader Moammar Gaddafi streamed back to their native Mali, triggering a chain reaction of violence that regional security forces and international partners, including France, have since struggled to quash.

On Wednesday evening, the Malian army’s Twitter account posted photos of the country’s red, yellow and green flag draped over 30 wooden coffins.

“Emotions were high,” the tweet said.

The funeral came two months after Islamic State leader Abu Bakr al-Baghdadi, who was killed by U.S. forces in October, called on followers around the world to take up arms after the group lost its strongholds in Iraq and Syria.

“From [Afghanistan] to Iraq to Yemen to Somalia to western and central Africa,” Baghdadi said in the September audio message, “sacrifice your lives if you have to.”

Militants with ties to the Islamic State and al-Qaeda, meanwhile, have expanded their reach in Mali and Burkina Faso by provoking feuds between ethnic groups and offering to protect victims of the bloodshed they are stoking.

The terrorists “broke down systems that usually deal with intercommunity violence,” Dennis Hankins, the U.S. ambassador to Mali, told The Washington Post in October.

More than 800 civilians have died in the violence since January, up from about 574 in the previous year, according to the Armed Conflict Location and Event Data Project.

And at least 140,000 Malians have fled their homes this year, according to a fall report from the Internal Displacement Monitoring Center — an almost sevenfold increase from the previous year.

Mali has sent a third of its armed forces into the country’s conflict-shaken center and north, where soldiers are supported by French and U.N. forces. (The United States provides some logistical help and intelligence.)

The attack this week in Gao was the third deadly ambush of Malian soldiers by extremist groups in two months.

The Islamic State also asserted responsibility for a strike in early November that killed at least 53 soldiers, and an al-Qaeda branch said it carried out September raids that killed 38 soldiers.

The militants are known for using increasingly sophisticated equipment.

A regional group known as the G5 Sahel force, composed of troops from Mali and four neighboring countries, said this month that it destroyed an extremist bombmaking workshop in Mali during a two-week mission.

West African leaders have earmarked $1 billion over the next five years to fund the fight, but security analysts say the effort needs more assistance from the international community.

“After the defeat of ISIS in Syria and Iraq, the Sahel region is the strategic future of globalized jihadism,” said Bakary Sambe, director of the Timbuktu Institute-African Center for Peace Studies in Dakar, using an alternative acronym for the Islamic State. “Terrorist groups are taking advantage of Libyan chaos and weak states to exploit vulnerabilities and plant local roots.”

Borso Tall contributed to this report.