BEIRUT - Islamic State of Iraq and Syria (ISIS) militants re-occupied Palmyra on Sunday, taking the ancient central city from government troops in a major advance after a year of setbacks in Syria and neighboring Iraq, a Syrian government official and the group said.

In retaking Palmyra, the extremist group appeared to be taking advantage of the Syrian and Russian preoccupation with Aleppo, timing its attack to coincide with a massive government offensive to capture the last remaining opposition-held neighborhoods in the northern city.

Palmyra, with its towering 2,000-year-old ruins, holds mostly symbolic meaning in the wider Syrian civil war, although its location in central Syria gives it some strategic significance as well.

Get Breaking News Delivered to Your Inbox

ISIS militants re-entered the city on Saturday for the first time since they were expelled by Syrian and Russian forces amid much fanfare nine months ago. The government’s first important win against the ISIS in the internationally renowned ancient city gave Damascus the chance to try to position itself as part of the global anti-terrorism campaign.

The militants had spent 10 months in Palmyra, during which they dynamited a number of temples and destroyed other artifacts.

Sunday’s takeover came hours after government troops and Russian air raids pushed the group out the city’s parameters. ISIS militants then regrouped and attacked the city from multiple fronts, forcing government troops to retreat. Palmyra opposition activists said the militants were going door to door in the city, looking for remnants of government forces.

Homs Province Governor Talal Barazi told the pan-Arab Mayadeen news channel that the IS attack on Palmyra is a “desperate” reaction to the Syrian government military “victories” on the ground. He said the forces that support terrorism including western countries, Saudi Arabia and Qatar wanted to “realize some type of gain” and chose Palmyra because of its international reputation.

Scores of Syrian troops have reportedly been killed in fighting around Palmyra in the last few days. While the battles are a distraction from the fight in Aleppo, they are unlikely to affect the government’s final push on the last rebel-held Aleppo neighborhoods. By Sunday evening, there was no sign that the army was shifting significant resources away from Aleppo for the fighting in central Syria.

The government and its allies have reportedly mobilized some 40,000 fighters for Aleppo.

“I don’t think the regime would withdraw forces from Aleppo to Palmyra and risk losing Aleppo,” said Rami Abdurrahman, the head of the opposition monitoring group the Syrian Observatory for Human Rights. “I think the regime’s priority now is to finish the battle for Aleppo before the end of the month for sure. As for Palmyra, the whole international community would stand by it against ISIS.”

Over the last year, ISIS has suffered a string of defeats in both Syria and Iraq, losing several towns and cities it had captured in 2014. It is now under attack in Mosul, the last major urban center it controls in Iraq. A Kurdish-led Syrian force, backed by the U.S., is also pushing toward Raqqa, the group’s de-facto capital in Syria, from the north. Meanwhile, Turkey is backing Syrian opposition fighters who have reached the outskirts of al-Bab, the IS stronghold in northern Syria.

In going for Palmyra, ISIS picked a soft target to demonstrate that despite its battlefield losses, it retains the ability to carry out large attacks.

Mohammed Hassan al-Homsi, a native of the city who runs Palmyra News Network, said ISIS is steering away from north Syria where the anti-ISIS international coalition and Turkey have focused their fight. With its losses in Iraq and elsewhere in Syria, the militants are eyeing new terrain. They chose Palmyra for its desert terrain linked to Iraq’s and its surrounding oil and gas fields, al-Homsi said.

State news agency SANA, quoting an unnamed military official, reported that the militant group received reinforcements from Raqqa, enabling it to attack with “large numbers” against military checkpoints around the city.

Russia’s Defense Ministry laid some of the blame at the feet of the U.S.-led coalition, saying it had scaled down its operation against Raqqa and allowed thousands of ISIS fighters to escape from Mosul. The ministry statement said more than 4,000 ISIS fighters have been deployed for the Palmyra takeover, implying that the militants attacking Palmyra had recently left Mosul.

The Observatory and the Palmyra Coordination group said ISIS militants fought their way into the city in a multi-pronged assault, forcing government forces to retreat to the south. A map distributed by the Observatory shows the areas controlled by ISIS to extend east, south and north of Palmyra, encompassing a number of strategic hills around the city and expanding the group’s presence in rural Homs. Palmyra lies in Syria’s largest province, Homs, which is mostly under government control.

Osama al-Khatib, of the activist-run Palmyra Coordination group which keeps in touch with residents in the city, said remaining government and allied troops were escaping from the southwestern edge of the city where the ancient ruins are. He said the few remaining families in the city are also attempting to escape. Al-Homsi’s Palmyra News Network said intensive airstrikes followed the ISIS takeover of the city. The group said ISIS fired on fleeing civilians while the group expanded its presence in rural areas around Palmyra.

In a video by the ISIS-linked Aamaq news agency, ISIS fighters were shown roaming a main square in the city that appears deserted at the foothills of the citadel that overlooks the ruins and the Palmyra Museum.

Russia had earlier claimed to have repelled an IS attack on Palmyra, saying it had launched 64 airstrikes overnight that killed 300 militants. But hours later, the activists said ISIS had seized a castle just outside the town that overlooks its famed Roman-era ruins.

Palmyra was a major tourist attraction before the civil war broke out in 2011 and is home to world-famous Roman ruins.

The capture of Palmyra last year by Syrian troops and Russia air force was seen as a major triumph for the government, which had previously had little success in battling the extremist group. After taking Palmyra, the two states turned their attention to wiping out the internal opposition in Damascus and Aleppo. After tightening the siege on the eastern part of Aleppo city, the most prized urban stronghold for the opposition, government and allied troops have been steadily carving into the besieged enclave in a ground offensive that began in late November.

Syrian media reported Sunday that of the original 17 square miles rebel-held enclave, only 4 square miles remain in opposition hands.