Tired of crises. Brussels, 16 June.

Middle East expert Mohamad Bazzi explains how the so-called Islamic State’s territorial losses in Syria and Iraq pushed it to focus on large-scale attacks around the world during the holy month of Ramadan.

BEIRUT – Throughout the Muslim holy month of Ramadan, militants and supporters of the so-called Islamic State group caused bloodshed and chaos, with bombings and mass shootings around the world. The spate of attacks began on June 12, when a gunman partly inspired by the group massacred 49 people at an LGBT nightclub in Orlando, Florida, and continued until the last days of Ramadan.

On June 27, suicide bombers killed dozens of civilians in Yemen and five people in a Christian village in Lebanon. The next day, militants stormed into Istanbul’s main airport, killing 45 people, in the deadliest terrorist attack in Turkey’s largest city this year.

On July 1, militants besieged a restaurant in the diplomatic quarter of Bangladesh’s capital, Dhaka, setting off an hours-long standoff with security forces and killing at least 22 patrons, most of them foreigners. On July 3, a massive car bombing in Baghdad killed nearly 300 people – the deadliest single bomb attack in the Iraqi capital since the U.S. invasion in 2003. The next day, suicide bombers struck three cities in Saudi Arabia, including an attack near the Prophet Muhammad’s Mosque in the holy city of Medina.

All of these atrocities were loosely organized or carried out directly by ISIS, or inspired from afar by its leaders. In recent months, Iraqi government forces, with U.S. air support, forced ISIS out of the western Iraqi cities of Ramadi and then Fallujah. But as it loses territory in Syria and Iraq, under pressure from western bombing and local military forces, the group is trying to project its strength by organizing or inspiring attacks around the world.

In an audio message released on May 21, two weeks before the start of Ramadan, an ISIS spokesman, Abu Muhammad al-Adnani, urged followers to carry out attacks in the West during the holy month in retaliation for U.S.-led airstrikes against the group’s strongholds in Iraq and Syria. “Know that in the heart of the lands of the Crusaders there is no protection for that blood, and there is no presence of so-called civilians,” Adnani said. He added that jihadists who heeded the group’s call “will gain the great reward for martyrdom in Ramadan.”

ISIS’s reach and ability to sow terror expanded beyond the Middle East more than a year ago, when it inspired attacks in Paris, Brussels and elsewhere in the West. But after the bloodshed it instigated this past Ramadan, the group is entering a new phase. To make up for its battlefield losses, the group is lashing out with more attacks, especially on civilian targets. As the only militant group that has been able to create its own state, ISIS is transforming into a more sophisticated and deadlier version of its main jihadist rival, al-Qaida, which has never controlled a state. “As the pressure mounts on ISIL,” CIA director John Brennan, using the U.S. government’s preferred name for ISIS, told the U.S. Senate Intelligence Committee last month, “we judge that it will intensify its global terror campaign to maintain its dominance of the global terrorism agenda.”

Since 2013, ISIS and al-Qaida have been competing for funding, recruits and prestige. The two groups often disagree over tactics: to avoid a backlash similar to the one they faced during Iraq’s civil war, al-Qaida’s leaders have urged their followers to avoid targeting Muslims. But ISIS leaders endorse the wholesale slaughter of civilians, including many Muslims that they regard as infidels, as epitomized by the spate of attacks on Muslim countries in Ramadan.

Both al-Qaida and ISIS want to overthrow what they view as the corrupt and “apostate” regimes of the Middle East – the “near enemy.” But the two groups differ on strategy. Al-Qaida’s leaders are mainly focused on the “far enemy” – the United States and the West.

That focus was partly motivated by U.S. actions abroad. For decades, Washington has supported repressive regimes in countries such as Egypt and Saudi Arabia, which spawned al-Qaida’s top leaders. Realizing that America was helping to prop up these regimes, the group targeted the “far enemy.” In doing so, al-Qaida’s leaders believed they would eventually force Washington to withdraw its support for the autocratic Arab regimes, and abandon the Middle East entirely.

But ISIS does not subscribe to al-Qaida’s vision. Instead, it mainly focuses on the “near enemy” – the so-called apostate regimes in Syria, Iraq and other parts of the Arab world. By late 2014, the group seized large chunks of Syria and Iraq. ISIS then proclaimed a caliphate in the territory under its control, and named its leader, Abu Bakr al-Baghdadi, as caliph and “leader of Muslims everywhere.”

With its self-declared caliphate, ISIS established a territorial base that has allowed it to govern, train thousands of fighters and generate income from illicit trade in oil and other resources – all on a scale larger than anything al-Qaida had achieved. ISIS has also established a larger recruitment effort and more sophisticated social media presence than al-Qaida’s. ISIS operatives recruited and trained thousands of disaffected Muslims from the West, especially Western Europe. Some of these militants have been sent back to create clandestine networks and carry out attacks against civilians.

ISIS also gained control of more resources and generated far more income than any previous jihadist group, including al-Qaida. ISIS generates money by selling oil and wheat, imposing taxes on residents of the territory it controls, and through extortion. In 2014, the group raked in about $2 billion, according to the U.S. Treasury Department. That included $500 million in oil sales on the black market, and up to $1 billion in cash stolen from banks while the group made its initial march on the border between Syria and Iraq. By contrast, al-Qaida has historically relied on donations from wealthy individuals, especially in Saudi Arabia, Kuwait and other Gulf Arab states.

But with new attacks, such as the assault on Istanbul’s Ataturk airport and the string of bombings in Saudi Arabia, ISIS risks provoking a massive crackdown by the governments it has targeted. Already, U.S. officials say the group has lost nearly half of the territory it once controlled in Iraq, and a quarter of the territory in Syria. Its illicit oil revenues dropped to about $150 million a year, from a high of $500 million in 2014.

Over the past two years, ISIS displaced al-Qaida as the dominant force in international jihadism. Baghdadi’s group has been more successful in its strategy, which relies on capturing and holding territory. But after its recent losses in Iraq and Syria, the group has reverted to its roots as a jihadist insurgency, bent on large-scale attacks that instill fear but achieve few tangible gains. In doing so, ISIS leaders are conceding that they might eventually lose their de facto capitals in Raqqa, Syria, and Mosul, Iraq. That means the group would squander the caliphate that has distinguished it from other jihadist movements and helped it attract new recruits.

ISIS has already suffered significant losses in its ranks: at its peak in 2014, U.S. officials say the group had about 33,000 fighters; today that number has fallen to between 18,000 and 22,000 militants in Iraq and Syria. But ISIS also has eight affiliates that have pledged allegiance to Baghdadi as caliph, and the largest of these groups – in Egypt, Libya, Pakistan, Afghanistan and Nigeria – have another 20,000 militants fighting under Baghdadi’s banner. By comparison, al-Qaida had only several thousand fighters at the height of its influence.

To combat this new and more complex range of threats posed by ISIS and its sympathizers, governments in the West and the Middle East will need to do more than simply continue military strikes against targets in Iraq and Syria. Deterring new attacks against civilian targets will require working toward political settlements in Syria and Iraq. It will also mean greater vigilance in monitoring clandestine networks set up by ISIS operatives – and adjusting to a new enemy that has proved it can adapt to new circumstances, and knows no limits.