An image from the Thiqa News Agency shows damaged cars after a suicide attacker detonated his small pickup truck outside a security office in Sousyan village in Syria on Friday. (Uncredited/AP)

Suspected Islamic State car bombs killed at least 50 people outside the northern Syrian town of al-Bab on Friday, a day after Turkey-backed rebels pushed the militants from their onetime stronghold.

Witnesses and a war monitor said the first blast killed 42 people in the nearby village of Sousyan, ripping through a crowd of displaced residents as they waited to receive permits for their return to al-Bab.

Hours later, local activists reported a second attack that killed eight more people.

The attacks hinted at the scope of the challenges facing the Turkey-backed rebel forces as they seek to restore security to areas they have retaken from the Islamic State.

“It drove right into the heart of the crowd,” said Khalil Abdulrahman, a Syrian journalist from al-Bab, describing the first attack. “There were bodies everywhere. Some of them were on fire. When I got closer to them, I realized I knew their faces. They were trying to go home.”

Images from the area showed blood and body parts on the ground.

The attacks came a day after Free Syrian Army rebels recaptured the town, pushing the Islamic State from its final foothold along Syria’s northern border with Turkey.

The offensive, which began in early December, was often grindingly slow despite the backing of Turkish warplanes, tanks and special forces. 

Turkey's military said Friday that the rebels had taken control of all of al-Bab and that work to clear mines and unexploded ordnance was under way.

The fighting has reduced much of al-Bab to a ghost town, its prewar population of about 100,000 having dwindled to the low thousands. Meaningful security is some way off for those who remained. Islamic State militants routinely mine the areas they abandon.

Friday’s attacks were a reminder that the group also remains capable of wildcat strikes against areas in which it has been defeated. Only last month, an Islamic State militant killed 48 people with a blast in a busy marketplace in the northern town of Azaz, three years after rebel forces recaptured the area.

“The situation in al-Bab is not stable,” Issa Khider, a local activist, said Friday. “ISIS dug trenches and tunnels all around this town, so everything on top of them is very weak. There are mines here that explode if you accidentally touch the hidden wire,” he said.

Arrested at an Islamic State checkpoint in 2014, Khider had faced the prospect of a brutal execution under the Islamic State, after one of its judges condemned him to death on charges of apostasy. On a video posted online Friday, the activist walked through the rubble of his now-deserted former prison, holding up the group’s torture implements and explaining how it had used them.

“I never expected to come to a place like this. I was blindfolded and humiliated,” he said.

Questions linger about  where the Turkey-backed rebel force will head next. 

Ankara’s military intervention last August complicated its relationship with the United States, which has supported a Kurdish-led force as its main spear against the Islamic State in Syria. 

Turkey views Syria’s Kurdish fighters as terrorists and is now pushing to send its own forces to Syria to recapture the Islamic State’s de facto capital, Raqqa.

A memorandum signed late last month by President Trump ordered the Pentagon and other national security agencies to draft a new proposal by late February for how to defeat the Islamic State in Syria and Iraq.

Turkey has proposed several different versions of a plan to takeRaqqa, all of which involve Turkish troops, more U.S. personnel and Syrian Arab fighters. U.S. officials have long argued that a successful assault will be difficult without the Kurdish militia that currently leads the ground fight against the Islamic State in Syria.

Zakaria Zakaria in Istanbul, Suzan Haidamous in Beirut and Brian Murphy in Washington contributed to this report.