In recent weeks, Erdogan has visibly sought to shore up his regional political position by ending the hostility in his relations with Israel and Russia. But until today, there was no indication that he might be in trouble domestically. If it is successful, it will be one of the most surprising coups in modern memory.

Until a few years ago, the shadowy Gulen was an Erdogan ally, and backed his rise, first as prime minister and then president. But in late 2013, Gulen challenged Erdogan’s tightening grip on power. Law-enforcement and judicial officials thought to be loyal to Gulen brought corruption charges against people close to Erdogan, in a campaign that appeared even to be going after Erdogan’s two sons. It was not clear who would win what appeared to be a clear struggle for control of the country. In early 2014, however, Erdogan struck back, purging hundreds of Turkish police officials who had been part of the investigation.

Over the last two years, Erdogan has punched back, closing opposition newspapers or firing their editors, including of the leading daily, Zaman. He consolidated his power last November, rerunning elections after a previous round in June had ended in a hung parliament.

The exact reasons behind the timing of the coup attempt was not clear, but it could be an effort to head off Erdogan’s plans to run a referendum later this year to change the constitution to confer more power on the presidency.

This story was updated at 9:25pm ET with statements made by Erdogan and the Alliance for Shared Values

📬 Sign up for the Daily Brief

Our free, fast, and fun briefing on the global economy, delivered every weekday morning.