ISTANBUL — An Istanbul courtroom opened a window on the state of American-Turkish relations as Metin Topuz, a Turkish employee of the United States Consulate in Istanbul, went on trial in one of several cases that showcase American powerlessness in the face of the intransigence of President Recep Tayyip Erdogan.

Mr. Topuz was ordered to remain in custody by the court Thursday at the end of a three-day hearing. He had been held in solitary confinement for 18 months until his trial began this week, despite repeated appeals by his lawyers for him to be released.

Turkish prosecutors have accused him of espionage and trying to overthrow the government, claiming that he had communicated extensively with followers of the United States-based cleric Fethullah Gulen within the ranks of the police who are accused of organizing a failed coup in 2016.

American officials have dismissed the charges as baseless and Mr. Topuz’s detention as a form of hostage-taking by the Turkish government.