Up until recently, the violence and unrest in Libya has been largely overshadowed by the bloody spectacle of the Islamic State in Iraq and Syria.

But a mass beheading video released by a western outpost of ISIS shows to what extent the Sunni extremist group has been trying to gain a foothold in Libya.

"There's no functioning central government, there's no real Libyan armed forces. It's a chaotic situation, and in that chaotic situation, there's opportunity [for ISIS] to grow," says Rex Brynen, a political science professor at McGill University with an expertise in the Arab world.

While the circumstances in Libya aren't exactly the same as in Syria, "it is similar in the sense that there is a civil war going on and that civil war has provided the space in which the Islamic State has been able to take root and potentially expand," says Christopher Chivvis, associate director of the Rand National Security and Defense Policy Center in Washington, D.C.

This past weekend, Muslim extremists claiming to be allied with the Islamic State in Iraq and Syria (ISIS) released a video in which they beheaded 21 Coptic Christian men kidnapped from Egypt.

LIBYA-VIOLENCE/

Fighting between rival factions in Tripoli is just one feature of the widespread chaos in Libya. (Reuters)

From the production values to the act itself, the footage follows the model set out by ISIS videos released in the last six months, which have depicted the killings of a number of Western journalists and aid workers and a Jordanian air force pilot.

In response to the latest video, the Egyptian military bombed the Libyan coastal city of Derna, which is thought to be a redoubt for many Libyan ISIS members.

The killing of the Coptic Christians is the second major incident involving ISIS sympathizers in Libya in the last month. In late January, members of the group attacked the Corinthia Hotel in Tripoli, Libya, killing 10.

'A shifting landscape'

Brynen says ISIS is trying to gain an upper hand by exploiting the political vacuum in a country with two opposing regional governments and a variety of well-armed and self-interested militias.

For months now, Libya has been the scene of a civil war between tribes and militias allied with the self-appointed, largely Islamist regional government in the western city of Tripoli and the internationally recognized government in the eastern city of Tobruk.

"Both of those governments depend on coalitions of militias and military forces which sometimes obey orders and sometimes don't," says Brynen. "It's a shifting landscape."

Much of the chaos is the direct result of the overthrow of the country's long-time dictator, Col. Moammar Gadhafi, during the 2011 rebel uprising backed by NATO, says Firas Abi Ali, a London-based senior analyst at the global intelligence group IHS.

Mideast Egypt Libya

The beheading of 21 Coptic Christian men by ISIS in Libya earlier in the year caused outrage in neighbouring Egypt. (Hassan Ammar/Associated Press)

During his iron rule, Gadhafi would not tolerate dissent, which is why there were no traditional political parties. After Gadhafi  was killed by rebel forces in 2011, "the only people that were in a position to truly organize themselves turned out to be primarily Islamist groups," says Ali.

Many of these groups gained immediate respect and public support, he says, because they took the lead in the physical fighting against the Gadhafi regime.

Some of these fighters were — and continue to be — aligned with al-Qaeda, while others are jihadists with more local concerns.

One of the bigger groups is Al-Ansar Sharia, a well-armed militia that was responsible for the 2012 attack on the U.S. consulate in Benghazi and has since taken control of that eastern city.

Fierce and committed

The operational strength and shifting allegiances of various tribal brigades and jihadist militias has kept the regional governments in Tripoli and Tobruk on a tenuous footing, and provided an opening for a group as fierce and committed as ISIS, says Ali.

While he estimates that ISIS "has an upper limit of a few thousand" fighters in Libya, Ali says many of them gained valuable military experience fighting alongside ISIS in the Syrian civil war.

ISIS's first major act in Libya, the Tripoli hotel attack in January, rattled the government in Tripoli and signalled that the group is seeking to assert its authority, says Rand's Chivvis.

"There's clearly a public-relations dimension to any act of terrorism, and in this case, a large part of it has to do with demonstrating their capability and intent to be the most radical of all the radical groups," says Chivvis.

Even so, Brynen says the growth of ISIS in Libya hasn’t been nearly as explosive as it has been in Iraq and Syria, for a very simple reason: cutthroat competition.

"There is certainly no analogy to the rapid expansion of [ISIS] in northern Iraq last year, largely because Libya is full of other militias who don't necessarily want their turf trod upon."