BEIRUT — Islamic State militants lost their last foothold in a major city and a strategic border crossing on Friday, as the Syrian and Iraqi militaries made significant advances, squeezing the militant group into a shrinking patch of territory near the border.

Syrian government forces, supported by intense Russian airstrikes and Iranian-backed militias on the ground, drove the militants from the last few neighborhoods they controlled in the eastern provincial capital of Deir al-Zour, the Syrian army said.

Across the border, the Iraqi army and allied Iranian-backed militias seized control of a crucial border crossing after taking most of the town of Qaim, Iraq, from the Islamic State, according to the Iraqi military chief of staff.

The military advances dealt a severe blow to the militant group, leaving it with fragments of its self-declared caliphate that once stretched from the center of Syria to the outskirts of Baghdad. They also provided yet another indication that President Bashar al-Assad’s fortunes have rebounded and that, with help from Russian and Iranian allies, the Syrian army can take back territory.