Libyan fighters are celebrating a major victory on Tuesday: They've driven ISIS out of parts of Benghazi, eastern Libya's largest city, building on advances in and around the city on Sunday.

ISIS isn't just losing in Benghazi. In its home base in Syria and Iraq, it's lost up to 30 percent of its territory from its peak in August 2014. And it's tried expanding abroad, officially declaring a wilayat — which literally means "province" and refers to ISIS's foreign franchises — in roughly a dozen countries.

These ISIS franchises showed some initial successes, for example in Libya, but since mid-2015 they have been struggling. Many of ISIS's wilayat have stopped growing and begun shrinking. Some ISIS affiliates have been wiped out altogether.

"The Islamic State has encountered one serious obstacle after another as it has tried to expand its presence beyond Syria and Iraq," Daveed Gartenstein-Ross, a fellow with the Foundation for Defense of Democracies and CEO of the consulting firm Valens Global, writes with threat analyst Nathaniel Barr in War on the Rocks on Tuesday. "These stumbles have gone largely unnoticed by the international media."

Gartenstein-Ross and Barr examined seven ISIS expansion attempts and found that each had serious problems. In every case, the ISIS franchise they looked at has either suffered a major battlefield defeat, had members targeted and killed in significant numbers by rival jihadist groups, or was defeated outright.

ISIS's many stumbles

"Overall, [ISIS] is having significant troubles expanding. Joining ISIL can be a fatal decision," Gartenstein-Ross told me, using another name for ISIS.

The first example he pointed to was a group called the Islamic Movement in Uzbekistan (IMU). IMU is a decades-old jihadist group with ties to the Taliban and al-Qaeda. In August, it formally pledged itself to ISIS, working with the already-established Afghanistan-based ISIS franchise.

Over the course of the next several months, the Taliban, once IMU's ally, sought out and killed IMU fighters in a targeted campaign aimed at destroying the group. This culminated in a November purge, wherein the Taliban killed 100 IMU fighters and allegedly captured its leader, wiping out the group entirely.

"What America and its agents could not do in 14 years, the Taliban did in 24 hours," one IMU supporter tweeted at the time.

ISIS's troubles in Algeria are, if anything, more dramatic. The group officially recognized a wilayat there, largely made up of former al-Qaeda fighters, in 2014. In October 2014, ISIS's Algerian branch captured a French mountain climber and beheaded him on tape.

The beheading attracted the attention of Algerian security forces, which shortly thereafter killed the group's leader. Later, in May 2015, Algerian forces killed five ISIS commanders and the overwhelming majority of its ground fighters in two days of fighting. Today, Gartenstein-Ross says, ISIS in Algeria is a "paper wilayat," with only six or seven fighters to its name.

ISIS's Yemen wilayat is in even worse shape.

You'd think Yemen would be the perfect opportunity for ISIS: It has no functional government and is in the midst of a civil war with major sectarian overtones. But the group has been riven by public infighting; Gartenstein-Ross and Barr documented roughly 100 defections in the past several months — out of a force estimated to be at most 1,000, and possibly much less.

"This outfit in Yemen is not very strong," Will McCants, director of the Project on US Relations With the Islamic World at the Brookings Institution, tells me. "They're, at the moment, a pretty bit player in that conflict."

Even relatively powerful ISIS franchises are having problems. The Libya branch lost its hold on the Libyan city of Derna in December, pushed out by a coalition of rival militant groups. Today, it controls only one major population center — the town of Sirte — and about 173 miles of coastal territory.

"In Libya, where they're strongest, they only control a thin strip along the coast," McCants says. "It's not nothing, but it's not nearly as impressive as what they control in Syrian and Iraq."

These cases, according to Gartenstein-Ross and Barr, are representative of ISIS's struggles to expand beyond Iraq and Syria.

"The group has stumbled or even fallen flat in almost every country where it has tried to establish a new wilayat," Gartenstein-Ross and Barr write. "The group’s failures as it tries to expand beyond Syria and Iraq could cast doubt on its entire global caliphate project."

The three reasons ISIS is stumbling

ISIS's struggles to expand reveal some major weaknesses inherent in the group's "DNA," as Gartenstein-Ross puts it, that limit its efforts to expand.

First, the group makes enemies out of other jihadist groups. Its ideological and strategic model depends on its claim to be the prophesied Islamic caliphate and its ability to prove that claim by holding territory. Other militant groups, in ISIS's mind, must submit to ISIS and hand over their territory — or be destroyed.

"That's a constant — they don't play well [with others]," McCants says. This leads to conflict with other jihadist groups such as al-Qaeda and the Taliban, which perceive ISIS as a threat and so move to crush new franchises as they're forming.

This is particularly problematic for ISIS because it thrives most in civil wars with sectarian elements — places where other jihadist groups already operate.

"Derna was always gonna be a tough nut to crack, because that's jihadist central in Libya," McCants says. "AQAP [al-Qaeda in the Arabian Peninsula] has long roots in Yemen, and has been more successful in exploiting the chaos."

Second, ISIS's showiness — the penchant for ghoulish murders and slick social media — can attract the attention of enemies before ISIS is really ready to take them on.

"That's one of the things that got them into trouble in Algeria," Gartenstein-Ross says. "The ostentatious beheading of [the French mountain climber] drew counterinsurgent resources down on them in a way that they weren't ready for."

Finally, ISIS is, weirdly enough, too top-down and bureaucratic. It isn't very good at selecting leaders who work well with locals or mediating internal, local disputes in its franchises.

"Despite their rebellious nature, they're a very rigid organization internally," Gartenstein-Ross explains. "In Yemen, the central leadership ended up contributing to that branch falling apart under the weight of a leader that the ISIL members don't agree with."

Don't count out the ISIS franchises yet

Despite ISIS's defeats in the Libyan cities of Benghazi and Derna, the group is still deeply entrenched in Sirte — and getting a number of new recruits. Its Egypt branch has withstood repeated assaults from the Egyptian government and has managed to pull off a number of high-profile terrorist attacks. And that's to say nothing of Boko Haram, which pledged itself to ISIS last year and is now recognized as Wilayat Nigeria.

"Around January 2015, when I finished the first draft of [my ISIS] book, it was laughable," McCants says of the franchises. "Then when I had to go back and revise four months later, I had to completely change the section. In that short time, they had made such a rapid advance. They've gotten stronger since then."

So the point is not to dismiss the franchises entirely. Rather, it's to recognize that they are not, as is often portrayed in the media, a sign of ISIS sweeping across the globe. It's an attempt by a terrorist group with very serious problems to try to create some breathing room outside of its troubled core holdings.

ISIS thrives on a narrative of victory. Now that the group's defeats in Iraq and Syria are too numerous and prominent for anyone to reasonably deny, the group has increasingly turned to the franchises to continue selling its narrative of constant territorial growth.

"They have this narrative of momentum; it's clearly very important to drawing people to the group, drawing organizations to ISIS," Gartenstein-Ross says. "This is an area of great vulnerability if [the truth] were widely known."

ISIS's affiliates help "maintain the fiction that this is an empire on the march," McCants says.

No matter how you judge the success of the franchises — and here, McCants is less optimistic than Gartenstein-Ross — both agree that any victories abroad don't come close to outweighing the losses the group has taken in Iraq and Syria.