YENISAKRAN, Turkey — A Turkish court on Monday ordered an American pastor to remain behind bars as his trial opened on charges that he aided terrorist groups in Turkey.

The pastor, Andrew Brunson, 50, who has worked in Turkey as a missionary for 23 years, has been detained for 18 months. He was arrested in the aftermath of the failed coup against President Recep Tayyip Erdogan in 2016, and American officials have been unsuccessful in their efforts to secure his release.

Mr. Brunson, leader of the Resurrection Church in the seaside city of Izmir, stands accused of aiding the Kurdistan Workers’ Party, the P.K.K., which has been waging a separatist insurgency inside Turkey for three decades. He is also accused of having links to followers of Fethullah Gulen, an Islamist preacher who lives in Pennsylvania and who Turkey claims masterminded the coup attempt.

In an emotional appeal to the court on Monday, Mr. Brunson said he had suffered a breakdown in jail, stopped eating and lost weight. He begged to be sent home under house arrest, but the judge upheld a judicial order last week that the pastor remain incarcerated for another month. Family and friends present for the proceeding had been hoping that Mr. Brunson would be freed now that his trial has finally begun.