ISTANBUL - Turkish President Recep Tayyip Erdogan said Thursday that Turkey would eliminate the threat from Islamic State militants in northeast Syria following its campaign to oust Kurdish fighters from the region. This came as international concern mounted over the fate of thousands of Islamist militants held in areas affected by the fighting.

"We will do whatever needs to be done" to prevent an Islamic State resurgence, Erdogan said in a speech in the Turkish capital, Ankara, just one day after announcing the start of a punishing offensive against Kurdish-led militias on the border.

Turkey says it aims to create a "safe zone" in northeast Syria, where millions of Syrian refugees living in Turkey could potentially resettle.

"After Turkey takes control of this region, everyone can be sure that [the Islamic State] will not reappear," Erdogan said, adding that Turkey would either imprison or deport the Islamist militants and their families.

Tens of thousands of Islamic State members and their families were detained in northeast Syria after the Kurdish-led Syrian Democratic Forces, which are allied with the United States, defeated the militant group earlier this year. Critics warned that the offensive could undermine security at the prisons and camps, allowing the Islamist militants to escape.

Erdogan's remarks came as fighting between the two sides intensified in villages and towns along the border Thursday. The president said Turkey had killed more than 100 SDF fighters as Turkish troops pushed deeper into Syrian territory, seizing two villages near the border town of Tel Abyad.

Kurdish officials said that at least eight civilians were killed by Turkish strikes since Wednesday but downplayed Turkey's claims its troops had advanced on key areas.

In a statement Thursday, the SDF said Turkish shelling had targeted a prison holding Islamic State fighters in the northeastern city of Qamishli. In Turkey, 12 people were wounded by mortar and rocket fire from Syria, the state-run news agency reported.

Turkey views Syrian Kurdish fighters as terrorists because of their links to Turkey's Kurdistan Workers' Party, or PKK, which has waged a decade-long battle in southeastern Turkey for greater autonomy. Turkey has launched cross-border attacks on PKK bases in northern Iraq since the 1990s. Last year, Turkish troops and allied Syrian rebels routed Kurdish militants from the border town of Afrin in northern Syria.

Erdogan had long vowed to target the Kurdish militias in Syria's northeast, where U.S. troops battling the Islamic State had partnered with the SDF. Turkey and the United States, who are NATO allies, were negotiating the parameters of a potential safe zone when Erdogan announced the planned offensive.

President Donald Trump said he was ordering the withdrawal of U.S. troops from the area ahead of the operation.

Syrian residents Thursday described scenes of mayhem as civilians fled clashes on the border. Also Thursday, international aid agencies warned of a humanitarian crisis, saying that an estimated 450,000 people living within three miles of the Syria-Turkey border were at risk.

"I had to leave with only the clothes I had on me," said Mikael Mohammad, a clothing shop owner from Tel Abyad, which lies a quarter-mile from the Turkish frontier. Mohammad and his family left the town as soon as the bombardment started Wednesday evening. He said they slept outside in a rural area some 25 miles south of Tel Abyad.

"The shelling is barbaric and indiscriminate. We spent the night in the open air among scorpions and snakes," he said. "Everything I rebuilt in the last few years, I may have just lost again."

In Ras al-Ayn, 75 miles east of Tel Abyad, a man who identified himself only as Nawras out of concern for his safety, said residents suffered a night of intense shelling and that villagers fled when airstrikes resumed in the morning.

"People are still leaving Ras al-Ayn as we speak," said Nawras, an electrician. "I'm being told that the city is still being targeted and that we should not consider going back for now."

Dadouch and Khattab reported from Beirut. The Washington Post’s Louisa Loveluck contributed reporting from Irbil, Iraq.