President Recep Tayyip Erdogan has in the recent weeks forced from office several of Turkey's big city mayors, in a purge of local officials designed to shore up support for his ruling party.

In a fast-moving and sometimes ruthless chain of resignations, four top city mayors have stepped down at Erdogan's request, paying the price for the ruling party's somewhat lacklustre performance in the April referendum on constitutional change.

Analysts say that after 15 years in power, the ruling Justice and Development Party (AKP) of Erdogan is genuinely worried about its levels of support, ahead of a critical election year in 2019.

"The dismissals of the mayors are for different reasons but it's all with the aim of improving the electoral position of the party," Ilter Turan, a professor of political science at Istanbul's Bilgi University, told AFP.

"The party is in a quandary as to why it is losing votes. The erosion of support was evident in the referendum.

"The president is trying to develop ways to turn the electoral tide around," he said.

- 'Impossible to do politics' -

First to go was Kadir Topbas, the mayor of Istanbul, a job Erdogan himself used to hold. Next went Recep Altepe, the mayor of Bursa, Turkey's fourth largest city and a key industrial hub.

Ankara mayor Melih Gokcek served in the post for 23 years ADEM ALTAN, AFP/File

After weeks of resistance, the third big mayor to fall on his sword was Melih Gokcek, in charge of Ankara since 1994 and an ineluctable presence on social media with sometimes mind-bending tweets including blaming western powers for earthquakes.

"An order cuts through iron," said Gokcek, emphasising he was only resigning because of Erdogan's wishes.

The latest big city mayor to resign was Ahmet Edip Ugur of the western city of Balikesir who stepped down on Monday with a lacerating farewell speech that shook Turkish politics to the core.

Choking with emotion and cheered raucously by supporters, Ugur said his family had been threatened amid the pressure to resign and the situation "had got beyond toleration".

"Unfortunately, it has become impossible to do politics within the AKP," he concluded. "I thank you all. Goodbye!" he said, sobbing.

Erdogan denied there had been any threat made to Ugur and said he had been "saddened" by the outgoing mayor's comments, adding that no-one was "untouchable".

- 'Not proof of control' -

The changes come after the 'no' vote came out on top in both Istanbul and Ankara in the April 16 referendum on expanding Erdogan's powers.

While the 'yes' was victorious nationwide, the outcome in both the Turkish capital and the country's biggest city rang alarm bells for the AKP as the two very diverse cities are seen as a microcosm for Turkey as a whole.

The resignations also follow a wide-ranging purge of Turkish society.

Over 50,000 people have been arrested since last July, accused of links to the Gulen movement -- which Erdogan blames for last year's failed coup -- while more than 140,000 public sector employees have been sacked or suspended.

The wider political context is also giving the AKP and Erdogan more than just food for thought.

While growth has impressed and surprised at over five percent, the economy remains brittle with inflation nudging 10 percent and much of the activity upsurge based on cheap credit which may yet unwind.

Analysts see growing frustration with the judicial and education systems while Kurdish support for the AKP could be dented by Ankara's staunch opposition to the Iraqi Kurdish independence poll and the jailing of Kurdish politicians in Turkey.

The AKP's political ally, the Nationalist Movement Party (MHP), is performing woefully and a dissident anti-Erdogan nationalist force led by the charismatic ex-minister Meral Aksener founded last month may represent a new threat.

Marc Pierini, visiting scholar at Carnegie Europe and former EU ambassador to Turkey, said the situation was bleak for the AKP, with its alliance with the MHP shaky, some "muted dissidence" within the ruling party and the new Aksener faction risking eating into its votes.

He said the "vast rejuvenation operation" at the top of the AKP was a "demonstration of force, but not necessarily proof of solid control."

- 'Snap polls possible' -

The referendum paved the way for a double helping of presidential and parliamentary elections in November 2019 where Turkey will for the first time choose a president who will rule without a prime minister.

These will be preceded by local elections in March 2019. Capturing Istanbul and Ankara from the AKP could give the opposition intensified momentum.

The Hurriyet daily reported that to prevent this timetable the government is considering early presidential and parliamentary elections in 2018, with even the second anniversary of the failed coup, July 15, 2018, mooted as a possible date.

"While AKP officials strongly refute the possibility (of early elections) it does not mean the possibility is entirely off the table," said Turan.

But this presented another dilemma for the AKP as while it may take time to change the electoral situation, there is a "strong suspicion" economic conditions will deteriorate, he said.