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.