BEIRUT -- Islamic State of Iraq and Syria (ISIS) militants withdrew Thursday from their last stronghold in Syria, a strategic town near the border with Iraq, following a government offensive that has effectively left the extremist group's fighters dispersed in villages and small towns in the desert.

The Syrian military declared the town liberated after intense battles that killed a large number of militants, including leaders. The military said they were still chasing other ISIS militants in different directions in the desert.

"The liberation of Boukamal is of great importance because it is a declaration of the fall of this group's project in the region generally and the collapse of its supporters' illusions to divide it, control large parts of the Syria-Iraq borders and secure supply routes between the two countries," said Army spokesman Gen. Ali Mayhoub in a televised statement.

Get Breaking News Delivered to Your Inbox

Syrian pro-government media said Syrian troops had clashed with remnants of ISIS in the town after they entered it late Wednesday. On Thursday, they reported the town clear of ISIS fighters.

Pro-Syrian media reported the town was liberated. Al-Ikhbariya TV's journalist reported from the road to the town, joyfully breaking out on camera: "Daesh is finished. Live."

The Britain-based Syrian Observatory for Human Rights said government forces and allied troops, including Iraqi forces who linked from across the border, were combing through Boukamal after ISIS militants withdrew.

With the collapse of ISIS in Boukamal, the militants have no major territorial control in Syria and Iraq and are believed to have dispersed in the desert west and east of the Euphrates River. U.S. officials estimated that there were between 2,500 and 3,500 ISIS militants around Boukamal and that leading members of the group were also believed to have taken refuge in the town. The group has a small presence near the capital Damascus.

ISIS has suffered consecutive defeats at the hands of separate but simultaneous offensives in Iraq and Syria by the Russian-backed Syrian forces and allied militias as well as U.S.-backed Iraqi and Syrian fighters.

Despite its fall, the group's media apparatus has remained active, though at a reduced level and with less success to tout, and its fighters are likely to keep up their insurgency from desert areas.

The swift fall of Boukamal in eastern Deir el-Zour province was accelerated after Iraqi forces seized Qaim, the town across the border last weekend, also controlling a strategic crossing between the two countries.

A senior Iraqi official said there was an agreement Tuesday to send Iraqi paramilitaries to Syria to take part in the Boukamal operation, adding that the Syrians were to supply them with weapons and gear. The official spoke on condition of anonymity because he was not authorized to speak to reporters.

An Iraqi spokesman for the Popular Mobilization Forces told The Associated Press last week that his forces, part of the Iraqi security forces, would participate in the operation and would head north to protect the borders and secure the road from Iran to Lebanon.

Boukamal was the last urban center for the militants in both Iraq and Syria where Syrian troops -- backed by Russia and Iranian-supported militias -- and U.S.-backed Syrian Democratic Forces were vying for control of the strategic border town.

Washington is wary of increasing Iran's influence in the area and backed the SDF in their bid to uproot ISIS from the borders with Iraq. The proximity of forces in the area raised concerns about potential clashes between them as they approached Boukamal from opposite sides of the Euphrates River, and now from across the border with Iraq.

It was not clear if the government seizure of the town meant the end of the race for control of territory previously held by ISIS.

So far the Kurdish-led SDF have focused on the area east of the Euphrates, seizing a number of oil and gas fields and securing large swathes of areas along the border with Iraq, as well as the newly liberated Raqqa city.