The mayor, Ekrem Imamoglu, was detained after prosecutors accused him of corruption and terrorism. The opposition said the arrest was politically motivated.

Turkey arrested the top political rival of President Recep Tayyip Erdogan on accusations of corruption and terrorism on Wednesday, days before he was set to be named the opposition’s candidate in the next presidential election.
The opposition blasted the arrest of the rival, Mayor Ekrem Imamoglu of Istanbul, as politically motivated and said that the government was trying to remove a potential political threat to Mr. Erdogan.
Mr. Imamoglu, 54, accused Mr. Erdogan, his associates and state prosecutors of orchestrating his arrest.
“This immoral and tyrannical approach will undoubtedly be overturned by the will and resilience of our people,” he said in a voice message sent when the police were at his home to arrest him and shared by his aides.
In a video shared on social media, also before his arrest, Mr. Imamoglu spoke from inside his closet as he knotted his tie and said that the government was “usurping the will of the people.”
“We are facing great tyranny,” he said. “But I want you to know that I will not be discouraged.”
Critics have long accused Mr. Erdogan, who became prime minister in 2003 and president in 2014, of using state institutions, including the courts and the security services, to undermine his political rivals. Mr. Erdogan’s defenders cite his history of electoral victories as proof of his popularity.