CAIRO — American military drones monitored Islamic State militants loading up hundreds of cars, buses and trucks with fighters and civilians and fleeing the city of Manbij, Syria, on Friday, as Syrian rebels advanced and the extremists lost yet another stronghold.
On Wednesday, the Libyan city of Surt, held by the Islamic State for more than a year, also fell to pro-government militiamen, and the militants lost the headquarters from which they had ruled more than 150 miles of Libyan coastline.
The two new victories against the Islamic State, also known as ISIS or ISIL, could have a significant effect on the group’s efforts to penetrate the West.
Manbij controlled one of just two crossings to Turkey from Syria, and its fall will probably deprive the extremists of that route. The other major crossing, al-Rai, is often under attack by anti-Islamic State factions. The route between Manbij and Jarabulus, Turkey, has been the route by which foreign jihadists have come to join the Islamic State in Syria, or to leave again for European destinations. It is also the largest city the group has lost in Syria.
Britain’s Channel 4 News broadcast images of jubilant residents burning their veils and cutting off their beards as the militants fled.
The battles in Syria and Libya had significant involvement from the United States. In Manbij, which had a prewar population of 100,000, many of the more than 300 American Special Forces advisers in Syria monitored the battle from makeshift command posts several miles away, and the American military launched more than 100 airstrikes in the city, sometimes as many as 20 a day.
In Surt, in the first eight days of August, American warplanes and armed Reaper drones carried out at least 28 strikes on Islamic State positions, which the Libyan militias said played a major role in their victory there.
Officials had worried about the Islamic State’s access to Surt’s long coastline, a short distance from Europe.
The reversal of the group’s fortunes is not limited to Syria and Libya. On Friday, the American military said that it had killed the man it identified as the head of the Islamic State in Afghanistan and Pakistan, Hafiz Saeed Khan, in an airstrike on July 26 in Nangarhar Province in eastern Afghanistan.
In Iraq, the country’s military took back Falluja in June, the third time it had claimed to do so, but the first time the claim proved to be true. American advisers were heavily involved in that operation, as well. And in July, the Iraqi military recaptured from the Islamic State the strategic Qayyarah Air Base, about 35 miles south of Mosul.
“The military side of this campaign is just coming together,” Brett H. McGurk, President Obama’s envoy to the coalition against the Islamic State, said in a speech last month. “The Iraqi armed forces have not lost a battle in over a year.”
Mr. McGurk said the Iraqi military’s successes had made it more feasible for a campaign to liberate the northern city of Mosul. With a population of about one million, Mosul is the Islamic State’s biggest urban center. But retaking it, he said, would be difficult.
While Islamic State fighters in Surt have not been completely subdued, they have lost all of their major positions and are hiding out in three small neighborhoods.
“Daesh is not eradicated totally; there are some of them somewhere else in the country,” said Martin Kobler, the United Nations secretary general’s envoy to Libya, using an Arabic acronym for the extremist group. “But they are not governing any longer.”
He added that the campaign’s success was a relief to the Libyan authorities as well as to Europeans worried about the group’s proximity.
In Manbij, residents reached by telephone and Skype confirmed American military reports that the extremists were on the run.
“The city is Daesh-free now,” said Adnan al-Hussein, an activist originally from the area. “A convoy of about 2,000 cars managed to leave Manbij and reach Jarabulus, of Daesh fighters, some of their families and civilians used as human shields to protect them from any attack,” he said.
Mr. Hussein said residents had reported airstrikes by the American-led coalition against the fleeing fighters.
The remaining Islamic State fighters appeared to be using civilians as human shields, said a senior United States military official who spoke on the condition of anonymity to discuss confidential battlefield assessments.
The official said the use of human shields could not be confirmed until the United States-backed Syrian opposition fighters were able to reach the once-contested parts of the city and secure them. The official said that the city center was booby-trapped with explosives and that fighters might have been left behind as suicide bombers.
That was also a concern in Surt, where pro-government militias said there was an unknown number of Islamic State fighters still in the city, along with thousands of booby traps and bombs.
The official said the rebel force assaulting Manbij had several thousand Arab and Kurdish militiamen, with Arab fighters taking the lead in many parts of the predominantly Arab city.
Manbij went wild with celebrations on Saturday as the Islamic State fighters departed. “Come and see how women are ululating in the city,” said Farouk Hussein, a member of the Syrian democratic movement and of Manbij’s local government. “Joy is everywhere in Manbij,” Mr. Hussein wrote via the messaging service WhatsApp.
The victory there, however, came at a high cost, with 203 civilians, including 105 children, killed in airstrikes, according to the Syrian Observatory for Human Rights, a monitoring group based in Britain. The observatory also said 1,019 Islamic State fighters had been killed.