By ANNE BARNARD
BEIRUT, Lebanon — Islamic State leaders had long promised their followers an apocalyptic battle — foretold, some believe, by the Prophet Muhammad — in an otherwise nondescript village they controlled in northern Syria.
But the warriors of the self-declared caliphate lost the village, Dabiq, in just a few hours over the weekend as Syrian rebels, backed by Turkey, closed in. To soften the symbolic blow, the Islamic State switched rhetorical gears, declaring that the real Dabiq battle would come some other time.
The about-face was part of a larger repositioning as the Islamic State loses ground, not only in Syria but also in Iraq, where forces backed by the United States began a drive on Monday to oust the group from the sprawling and strategically vital city of Mosul. On the defensive in both countries, the group has been making preparations for retrenchment and survival.
Hundreds of Islamic State fighters and their families have fled to the group’s de facto capital, the northern Syrian city of Raqqa, in recent days, according to several residents of that city who asked not to be named to avoid reprisals. They said that the arrivals had come from Mosul, as well as from areas around Dabiq in the Syrian province of Aleppo, and that they were waiting for the Islamic State authorities to find them housing.
The group, also known as ISIS or ISIL, has also been laying the ideological groundwork to maintain its appeal in straitened circumstances. As it suffered on the battlefield in recent months, the group began signaling that a drastic contraction or even a failure of its territorial proto-state would not spell defeat.
“The generation that has lived in the shadow of the caliphate, or has lived during its great battles, will be able — God willing — to keep its banner aloft,” the group’s weekly Arabic-language newsletter, Al Naba, said in June.
The article reminded followers that the group’s predecessor, the Islamic State in Iraq, had survived by fading into the desert after military defeat during the United States occupation, only to re-emerge more formidably in Syria years later and eventually seize much of Iraq, including Mosul.
More recently, as Dabiq was surrounded on three sides by the Turkish-backed rebel force, Islamic State followers “began to frantically explain why the approaching showdown in Dabiq would not be THE showdown,” Will McCants, the author of “The ISIS Apocalypse,” wrote on the blog Jihadica.
Islamic State media outlets pointed out that other conditions for the prophesied battle had not materialized, like the appearance of a “crusader army,” or the Mahdi, a messiah-like figure, or an 80-nation coalition of fighters.
Dabiq has been central to the group’s identity. The Islamic State’s online magazine is called Dabiq, and its news agency, Amaq, is named after the surrounding area. And many Islamic State opponents seized on the village’s fall and the recalibration of the group’s messaging as proof that its grand visions were falling apart.
“Due to unforeseen circumstances, ISIS declares that The Final Battle of The Apocalypse has been postponed,” Karl Sharro, a London-based architect with Lebanese-Iraqi roots who moonlights as a satirist of Middle East politics, teased on Sunday as the rebel troops swept in.
But some analysts cautioned that the shift in language could be just the latest example of the group’s pragmatic flexibility, propaganda savvy and staying power.
Abu Muhammad al-Adnani, the senior Islamic State strategist killed in an August airstrike, had vowed that the group could outlive any single leader. As Kyle W. Orton, a fellow at the Henry Jackson Society, a research institute in London, wrote on Twitter, “The real problem is: what if he’s right?”
With the recapture of Dabiq and other recent indications that the group is weakening or retreating, a constellation of forces involved in Syria — including the United States, Russia, Iran, Turkey, the Syrian government, Syrian rebels and Kurdish militias — are jockeying for dominance.
Many enemies of the Islamic State are also enemies of one another. They accuse one another of using the group as a weapon, of effectively allying with it, and of driving its fighters into enemy territory to be someone else’s headache. They are also racing one another to win ground from the group.
Whoever seizes what is now Islamic State territory will control the border between Iraq and Syria, as well as fault lines between Kurdish groups seeking autonomy and populations that oppose them.
For instance, the seizing of Dabiq and other towns by Turkish-backed Syrian rebels has sharpened tensions with Kurdish militias. The Kurds wanted to take the area from the Islamic State to unite two separate Kurdish enclaves; blocking them was a main aim of the Turks, who consider the Syrian Kurds allies of a Kurdish insurgency on Turkish soil.
And as the Mosul battle heated up on Tuesday, there was talk of a higher-stakes race to Raqqa, with the French foreign minister, Jean-Marc Ayrault, saying that the United States-led coalition should push on to that city next.
“Not to go on to Raqqa would be a bad mistake,” Mr. Ayrault told reporters, days after the Turkish president, Recep Tayyip Erdogan, said that his government was discussing a joint Raqqa operation with the United States.
Meanwhile, the Syrian government — on state news media and in conversations with several foreign diplomats — has accused the United States of targeting Syrian soldiers with airstrikes to open routes for Islamic State fighters to escape into Syria from Mosul.
The United States-led coalition killed scores of Syrian soldiers in a bombing raid last month that American officials described as an accident. But Syrian and Russian officials say the attack, in the eastern province of Deir al-Zour, was deliberate, noting that it went on for nearly an hour and hit a long-established, clearly marked base.
President Bashar al-Assad of Syria and his backers also disagree about how to handle the Islamic State. Mr. Assad has long vowed to retake the whole country, including Raqqa and Deir al-Zour, but Russia has been loath to spend resources on Syria’s eastern desert provinces bordering Iraq, focusing instead on the more heavily populated spine of cities in the west. Iran, the Syrian government’s closest ally, has more reason to oust the Islamic State from Sunni areas straddling the border between Syria and Iraq, a country where Iran is deeply enmeshed and influential.
The Syrian rebels that ousted the group from Dabiq and other parts of northern Aleppo Province also oppose Mr. Assad; their allies in the city of Aleppo are surrounded by pro-government forces and suffering intense Russian bombardment.
Seizing the border area that includes Dabiq helped the rebels in several ways: It showed their potential backers that the rebels could fight the Islamic State. It also carves out a relatively safe area for their Syrian supporters; some refugees have already returned to the area.
And it helps delegitimize the Islamic State’s ability to compete with the rebels for supporters and fighters, like Sunni Muslims who also believe in the prophecy about Dabiq.
“Dabiq is free,” Mohammad Alloush, a spokesman for one of the rebel groups who has served as a negotiator in peace talks, declared on Twitter, referring to “the dream” that the group “used to exploit the simple-minded.”
“Your caliphate is a myth,” Mr. Alloush said.
“I guess after that, thousands of fighters will flee Daesh,” he added, using an Arabic acronym for the group. “And the end-times battle of Dabiq does not belong to you.”
Muhammad al-Ahmad, the commander of a rebel group that took part in the battle, posted on Twitter that the defeat would end the Islamic State’s “abuse of the name of Dabiq,” adding a note to “our people in besieged Aleppo” that “we promise to meet you soon.”
Abu Assaad Dabiq, a rebel fighter from the area who helped liberate it over the weekend, saw his father on Monday for the first time in two years. The son had participated in several battles against the Islamic State and fled Dabiq, his hometown, just before the group took it over in 2014.
“They kept threatening my father that they will slaughter me because I’m an infidel and not a good guy,” he said in a telephone interview on Monday, using his nom de guerre to avoid reprisals. “He told them, if it’s proven that I’m not good, he will kill me himself.”
Mr. Dabiq said he was waiting for his wife and two children to return from Turkey, watching a full moon from a hill where he used to visit the tomb of Suleiman bin Abdel Malek, an eighth-century caliph who died there waiting for the great victory in the prophesy. But Islamic State militants had destroyed the tomb, he said: “They exploded the whole place.”