ISTANBUL — President Recep Tayyip Erdogan of Turkey warned Western nations that he would continue to release people who were thought to be members of the Islamic State and send them back to their home countries if governments continued to pressure Turkey with sanctions.

Speaking to reporters on Tuesday shortly before leaving Ankara for a visit to the United States, Mr. Erdogan was mostly aiming the remarks at the European Union, which has proposed a system for imposing sanctions on Turkey over its unauthorized gas drilling in the eastern Mediterranean.

The comments came a day after Turkey said it had begun deporting Islamic State fighters it had captured, starting a program to repatriate the detainees that has strained ties with European countries.

Mr. Erdogan also took a tough line toward an American detainee who was deported by the Turkish authorities on Monday and became stranded at the Greek-Turkish border after being turned back by the Greek border police. Turkish officials said on Monday that the American was an Islamic State fighter captured last month in northeastern Syria.