A member of the Russian army works in the ancient Syrian city of Palmyra, which was recaptured from the Islamic State last week. (AFP/Getty Images)

Turkish-backed rebels in northern Syria have been driving Islamic State militants out of vast areas along the frontier with Turkey, seizing a key border town from the extremist group in their latest gains.

The capture overnight Thursday of Rai, about 40 miles northeast of Aleppo, by groups affiliated with the umbrella Free Syrian Army deprives the Islamic State of one of its last border crossings from Turkey into Syria. Rai had been a key conduit for the group to funnel fighters and weapons.

The takeover — confirmed by the rebel groups and the Syrian Observatory for Human Rights, a Britain-based monitoring organization — represents a major setback for the Islamic State, which depends heavily on smuggling pathways through Turkey.

The militant group’s territory in Syria and Iraq has been shrinking substantially because of advances by U.S.-backed forces and pro-government fighters in Syria. Among the important gains was the recapture last week of the ancient city of Palmyra in Syria by forces — supported by Russian warplanes — allied with President Bashar al-Assad’s government.

“The rebels liberated al-Rai completely yesterday evening after intense clashes with ISIS,” said Col. Haytham Afisi, a commander of the 51st Brigade, a rebel outfit involved in the operation. The Islamic State, a radical al-Qaeda offshoot, is also known as ISIS, ISIL and, in Arabic, Daesh.

During their assault on the town, Afisi said, the rebel forces received support from Turkish artillery and from airstrikes by a U.S.-led coalition that is fighting the Islamic State in Iraq and Syria.

The rebel advances appear to be a success for Turkish policy in Syria. U.S. officials hope Turkey will focus more on combating the militants along a border that, for much of the conflict, has been a porous gateway for Islamist fighters.

Turkey, a fierce opponent of Assad, has provided the rebels with weapons and logistics as they have made their way east from Azaz, another border town about 30 miles north of Aleppo. The rebel fighters have reclaimed more than a dozen villages in the area.

Video footage posted on social media purports to show the rebels hoisting assault weapons as the storm into Rai on trucks. Large explosions resulting from apparent air raids by the U.S.-led coalition reverberate in the background.

In one video, a rebel fighter stands in front of a group of fatigue-clad militants, shouting that the “Free Syrian Army has liberated al-Rai.” The group chants, “God is great!”

Turkey also seeks to use the rebels to blunt a separate push by Kurdish militants in Syria, who have U.S. support. Turkey claims that the Kurds have strong links with separatist Kurds in Turkey and has called for Washington to cut ties with the Syrian Kurds.

With rebels in control of Rai’s border crossing, they have carved out more breathing room in Syria’s northwest and appear poised to use the crossing to bring reinforcements to ­opposition-held areas in Aleppo.

In February, a Syrian government assault, backed by Russian airstrikes and militia from Iran and Lebanon, dealt heavy blows to rebel fighters in the countryside north of Aleppo.

Those assaults in turn threatened to vanquish rebels in their urban stronghold in the eastern part of Aleppo — a scenario that could prove fatal to the five-year rebellion.

A partial cease-fire backed by Russia and the United States has since led to a substantial reduction in hostilities, despite violations alleged by both sides. The agreement does not stop attacks against the Islamic State.

“There is conversation with the Turkish military and government to talk about opportunities to intensify support to those groups and to push Daesh east from the current line,” Reuters quoted the U.S. ambassador to Turkey, John Bass, as saying.

In Iraq, meanwhile, forces moved into the center of Hit, the military said. Hit is an important foothold that would put troops closer to the northern city of Mosul, the Islamic State’s main base in Iraq.

Zakaria Zakaria in Istanbul and Liz Sly in Baghdad contributed to this report.