But the president has evidently calculated that the changes will pay off before nationwide municipal elections next year. Political rivals suggest that Mr. Erdogan may even be preparing to call early presidential elections in July, if it appears that his popularity is slipping.
The moves against the mayors come after the president already imprisoned and fired tens of thousands of police officers, judges, civil servants, journalists and academics in the aftermath of last year’s failed coup. In the largely Kurdish southeast, he replaced the mayors in 82 of 103 municipalities.
After his victory in the April referendum, he reassumed the leadership of his Justice and Development Party, or AKP, in May and then started a cull within the organization he had founded, swiftly changing 19 seats on its 50-member executive board.
More personnel changes are expected in coming months, Turkish political journalists are reporting, as the party holds a series of regional congresses ahead of a general party congress early next year.
“This is in fact our people’s demand,” Mr. Erdogan told a biannual party congress in October. “We have to undertake this renewal process, need for change, and demand for refreshing, with our own will. If we do not do this ourselves, our people will do it at the ballot boxes.”
Mr. Erdogan remains by far the most prominent and popular politician in Turkey. But his party has slipped to 43 percent from 49 percent in popular support, according to one recent opinion poll.
His officials and even family members have been tainted by growing accusations of corruption, including that ministers accepted bribes worth millions of dollars, a case now before a United States federal court.
The Erdogan-backed referendum only narrowly passed in April, an indication that he cannot take the presidential race for granted, particularly in Turkey’s largest cities. Government officials say the mayors were not performing satisfactorily.
“Municipal services have stalled,” a presidential adviser explained recently in an interview. He spoke on condition of anonymity in accordance with standard protocol in the presidency. “That’s why people are not happy.” he said. “That’s why President Erdogan is saying we need a shake-up.”
Mr. Erdogan has been warning party members that they must win 51 percent of the vote to secure the presidential election, a harder task than winning a simple majority under the parliamentary system.
“What is more natural than us strengthening our party with new names?” he asked in the same October speech. “The reason we are discussing this issue so much is the current difficult conditions. These hard roads cannot be walked with tired bodies.”
One of the aims is to bring in new energy and fresh ideas because Turkey’s electorate is becoming increasingly younger, Mehdi Eker, vice president of the AKP and member of Parliament, said in an interview. “We are a young population,” he said. “The median age is something like 32.”
One of the first things the new mayor of Ankara has done is to extend public transportation to run all night, a decision popular with the youth. Another measure has lowered the minimum age for holding public office to 18 from 25.
Yet despite Mr. Erdogan’s dominance of the party, the mayors did not go meekly. Several resisted for weeks, reluctant to step down.
Newsletter Sign Up
Thank you for subscribing.
An error has occurred. Please try again later.
You are already subscribed to this email.
Perhaps the chief resister was Melih Gokcek, an ebullient self-promoter who had served 23 years as mayor of Ankara, and whose position had seemed unassailable.
After several meetings with the president, he eventually yielded. “Not because I am unsuccessful, not because I am tired,” he told city officials and supporters at a final council meeting on Oct. 28. “Only and only, I am fulfilling Recep Tayyip Erdogan’s request.”
There was no love lost between Mr. Gokcek and Mr. Erdogan, both former mayors, and both ambitious businessmen and politicians.
Mr. Gokcek wielded enormous patronage in Ankara through his municipal construction projects and local welfare programs, and with more than four million followers on Twitter, he was a potential political rival to Mr. Erdogan.
Yet many residents and local officials were glad to see him gone, complaining of corrupt practices and ill-judged construction projects that have created unsustainable urban sprawl and even a shortage of water.
The Chamber of City Planners in Ankara fought 600 court cases against Mr. Gokcek over the years, challenging the legality of much of his municipal work, said Orhan Sarialtun, the group’s president.
Political opponents criticized the manner of the mayor’s dismissal, but did not shed many tears.
“We are objecting to his resignation because it is against democracy,” said Aylin Nazliaka, a member of Parliament from Ankara who has been in dispute with the former mayor for years. “However Melih Gokcek is of such a nature that no one can defend him,” she said.
Putting a new broom to his administration and changing mayors who could not deliver the vote makes political sense, said Soner Cagaptay, an author and political analyst. Mr. Erdogan cannot afford to lose the big cities, especially Istanbul, his hometown and power base, Mr. Capatay said.
But the vetting has left a bitter taste. The mayor of Balikesir, the rich industrialist Edip Ugur, complained that his family had been threatened and resigned in tears from the party and from his job on Oct. 30.
In an interview in December at a sprawling conference center, his last project as mayor, developed on land that was once a city slum, Mr. Ugur said that Mr. Erdogan had wooed him assiduously to join his new party back in 2001. They had enjoyed success because the party had been open to discussion and new ideas, he said.
Reading from his resignation speech, Mr. Ugur lamented that the party was turning into an autocracy and was devouring its own.
“Does loyalty seem to be overtaking meritocracy,” he asked. “This reform and innovation within the AK Party is turning into an autophagy.”
Rusen Cakir, an experienced political columnist and founder of a live-streaming outlet, Medyascope TV, said the decisions may leave the party weaker, even if they concentrate more power with the president.
“The greatest secret of his success has always been teamwork,” Mr. Cakir said of Mr. Erdogan in a recent video blog. “At every stage he shuffled his team, but he always worked with very strong teams each time.”
But the president was no longer sharing power with strong players. “Step by step, he purged everyone who is capable of standing on their own feet,” Mr. Cakir said. “He does not share power anymore, he allocates.”