ISTANBUL — President Recep Tayyip Erdogan of Turkey was dealing with a rapidly changing political reality on Tuesday, meeting with party leaders to discuss a cabinet shake-up days after a disastrous mayoral election campaign in Istanbul in which his preferred candidate was dealt a humbling defeat.

As the dust settled on that loss for Mr. Erdogan’s governing Justice and Development Party, or A.K.P., observers looked for signs that he would soften his aggressive prosecution of people widely regarded as minor political players after a failed coup attempt in 2016.

Three potentially significant trials are scheduled for this week, and they are expected to be closely watched by foreign governments, which have been troubled by Mr. Erdogan’s efforts to crack down on huge swaths of the opposition.

In light of the results in Istanbul, a sliding economy and escalating foreign policy problems — including the threat of sanctions from the United States over his purchase of the S400 Russian missile system; a refugee crisis brewing in Idlib, Syria; and European opposition to Turkish drilling in the Eastern Mediterranean — the dynamic for Mr. Erdogan is shifting.