Nearly two months after President Obama first vowed to eradicate ISIS, this cancer is spreading in North Africa — within striking distance of Europe’s soft underbelly.

On Sept. 15, a group of Algerian jihadists broke away from the Al Qaeda in the Islamic Maghreb network to pledge allegiance to ISIS and its leader, Abu Bakr al-Baghdadi. The self-proclaimed “Soldiers of the Caliphate in Algeria” proved their worth days later, ambushing a group of French tourists in a popular Algerian national park, kidnapping and beheading one of them.

On Sept. 23, the new group Soldiers of the Caliphate in Egypt popped up, threatening attacks against the country’s anti-Islamist government and US interests. In Egypt’s Sinai, the Ansar Bayt al-Maqdis network, the instigator of a costly 18-month insurgency, has increasingly adopted ISIS tactics to intimidate the local population. ABM has taken to publicized beheadings and flash parades-of-force in local villages, while several of its members have admitted to receiving tutelage and funding from ISIS.

In Tunisia, once-struggling guerrillas on the mountainous frontier with Algeria received a boost from jihadists returning from Syria, even as messages of support for ISIS increase from groups fighting in the area.

Ironically, most of North Africa’s jihadist groups declined to associate themselves with ISIS until the United States commenced its intervention in Iraq and Syria.

Terrorist heavyweights such as Abdel Malek Droukdel of AQIM, Mohammed Zahawi of Ansar al-Sharia in Libya and Mokhtar Belmokhtar of al-Mourabitoun — men who’d fought alongside Osama bin Laden and Ayman al-Zawahiri — refused to pledge allegiance to ISIS even after it captured vast territory in Iraq in June and declared a caliphate.

Yet now North Africa’s younger jihadist generation is breaking away from al Qaeda’s flailing old guard, seeking instead to get on the ISIS bandwagon to suckle the benefits from its seemingly unstoppable success — primarily its wealth.

And the sporadic US airstrikes in Iraq and Syria seem to have boosted ISIS’ legitimacy in the eyes of North Africa’s jihadists, as shown by a disturbing rise in public pledges of support and allegiance.

The only thing more worrying than the spike in grassroots support for ISIS in North Africa is the readiness of the international community to repeat the mistakes of Iraq and Syria.

Nowhere is this more apparent than in Libya — a country primed to allow jihadists of the most dangerous breed to form a terror state mere miles from Italy.

As they did in Syria, Qatar and Turkey have been backing an array of Islamist militias in Libya, many of which work openly with jihadist groups.

In August, these militias took control of the capital Tripoli, forcing the Western-recognized parliament to the secularist haven of Tobruk near the Egyptian border.

A loose coalition of tribes and anti-Islamist revolutionaries led by former Gen. Khalifa Hifter has been on the defensive nationwide. In August, Ansar al-Sharia pushed Hifter’s forces out of their bases in Benghazi, and soon declared the area an Islamic Emirate.

Libya provided a training ground and rallying point for North African fighters heading into Syria. When those fighters return, it will similarly serve as a base of operations against US allies Tunisia, Algeria and Egypt.

The al-Battar Brigade, a Libyan militia in Syria allied with ISIS, has already returned and established itself in Benghazi, while local groups such as Majlis Shura Shabaab al-Islam in the city of Derna continue to pledge allegiance to ISIS.

Yet when the UAE and Egypt attacked targets in Tripoli in September to help anti-Islamist militias, the US reaction was condemnation.

There are no perfect options, but the West has no choice but to take sides in North Africa’s jihadist fight, lest it face another terrorist behemoth fueled by ultra-fine Libyan crude and armed with hundreds of shoulder-launched surface-to-air missiles.

This effort must begin with a determined effort to ensure that anti-Islamist militias have everything they need to outgun their Islamist opponents, and to bolster the abilities of Egypt and Algeria to protect their borders.

And the West must finally bring an end to Qatar’s support for extremist groups region-wide.

As the world comes to terms with the horrific consequences of inaction in Syria and Iraq, those who oppose extremism have no excuse for standing on the sidelines as Libya descends into even greater chaos — threatening to drag the entire region down with it.

Daniel Nisman is president of the Levantine Group, a Middle East-based geopolitical risk and research consultancy.