At the same time, Mr. Erdogan has become increasingly isolated, frustrating old allies like the United States by refusing for years to take firm measures against the Islamic State. He has recently gotten serious about the militant group, but that appears to have brought new problems: Turkish officials say they believe that the Islamic State was responsible for the suicide attack that killed 44 people on Tuesday in Istanbul’s main airport, a major artery of Turkey’s strained economy.

He has helped reignite war with Kurdish separatists in Turkey’s southeast, and hundreds of civilians have died in the fighting, which began last summer. He alienated Moscow last fall when Turkish forces shot down a fighter jet that he said had strayed into Turkish airspace.

He had grown so alone that this past week he moved to make peace deals with Russia over the jet’s downing and with Israel over its killing of several Turkish activists on a Gaza-bound flotilla in 2010, after railing against both countries to voters.

“I think this is an indicator of how desperate they are,” said Cengiz Candar, a visiting scholar at the Stockholm University Institute for Turkish Studies.