BEIRUT -- Militants with the Islamic State of Iraq and Syria (ISIS) came into the Syrian town with a hit list. By the time they left three weeks later, more than 70 civilians had been killed -- shot or beheaded, their bodies dumped in farms and ditches.

The apparent revenge killings in the town of Qaryatayn underscore the ability of the extremists to inflict heavy losses even when they're in retreat -- and portend more violence as they fight to hang on to their last strongholds in Syria.

News of the gruesome slayings began to emerge late Sunday, after ISIS militants were driven out by advancing government troops. Terrified residents said they watched the slaughter from their windows or in the streets.

Get Breaking News Delivered to Your Inbox

One former resident said his surviving family members walked for miles to find cell phone coverage so they could tell him of the deaths of his uncle, two cousins and a fourth relative. Another uncle remains missing.

"They came into town with a hit list," said Abdullah AbdulKarim, adding that 35 of the 50 militants who overran the town late last month were originally from Qaryatayn. He said the militants accused many of their victims of collaborating with the government but many others were also caught in the revenge killing.

"Our curse is from within us," he said, speaking to The Associated Press from northern Syria, where he fled years ago.

Once a predominantly Christian town known for its ancient monastery, Qaryatayn has changed hands between ISIS and the Syrian government several times during Syria's civil war. Parts of the 1,500-year-old St. Elian monastery were demolished the first time ISIS took over the town in 2015 and thousands of its Christian residents fled, fearing the extremist group's brutality.

An AP video, filmed as Syrian government troops recaptured Qaryatayn on Saturday, showed several bodies lying in the streets. In the video, a town resident said ISIS "monsters" killed more than 100 people, including soldiers and civilians.

"These are people who don't know God, they don't know anything. They killed children and women with knives, they beat women, broke their arms," he said, speaking on condition of anonymity out of fear for his own safety.

The Britain-based Syrian Observatory for Human Rights said it had documented the killings of at least 128 people in Qaryatayn, including at least 12 killed by government forces on suspicion of aiding the ISIS militants.

AbdulKarim and Mohamed Hassan, an activist who runs the Palmyra Network News, put the death toll at 75 civilians, saying many more remain unaccounted for. They said the dead included some who were shot by government forces.

But Hassan said most of the slayings were by ISIS militants. "It seems it was mostly revenge," he said.

Another activist network, the Palmyra Coordination Committee, released the names of 67 civilians who were confirmed killed and said the number was likely to rise. It said at least 35 of the dead were found dumped inside a ditch.

Talal Barazi, the governor of Homs province, said ISIS "terrorized" residents for three weeks, adding that most of the dead were townspeople who were government employees or were affiliated with Syria's ruling Baath party.

He said at least 13 residents remained missing and six bodies had not been identified.

ISIS militants first seized Qaryatayn in August 2015, and relied on its strategic location to defend another of their bastions, the historic city of Palmyra. With Russian backing, Syrian government troops regained control of Qaryatayn in April 2016. But ISIS, facing major setbacks in Syria and Iraq, launched a new offensive on the town in late September and recaptured it.

AbdulKarim said during the three weeks that ISIS controlled the town, the militants went door to door looking for people they accused of collaborating with the Syrian government.

He said his uncle, who was a local mayor, and two cousins were shot after they were taken to an undisclosed location. Another uncle remains missing.

"They took people to show them bodies dumped in an open area to let them know they were killed, but also to terrorize the public," AbdulKarim said. He said the extremists barred residents from burying their dead.

He said the advancing government troops also killed civilians, but residents were too afraid to report the government killings.

AbdulKarim and the Observatory said the militants took Qaryatayn's police chief, his wife and other security personnel as hostages to negotiate their exit after government troops encircled the town. About 200 militants evacuated the town, before government forces marched in, they said.