“Where are the onions? I can’t cook green beans without onions,” a middle-aged woman tells the vendor at one of Turkey’s new “people’s vegetables stalls” in Istanbul. “Where’s the aubergine and peppers? If you don’t have those, then what’s the point?”

Several dozen people queued at the white tent in the middle of Taksim Square one morning last week, one of 150 set up in Istanbul and Ankara by President Recep Tayyip Erdoğan to combat what he calls “food terrorism” – a steep rise in the cost of basic goods that is souring public opinion against the government before crucial local elections on Sunday.

The stalls, which are selling vegetables below the market rate, are popular – and needed. The lira crash last year has sent inflation soaring to 20% and last month Turkey entered a recession – a sober end to years of an average of 5% economic growth, which has buoyed Erdoğan during his 16 years in office.

Turkey is not due to hold a general election until 2023. As a result, what should have been routine local elections have instead become a fiercely contested ballot fought not just on the fragile economy, but on Erdoğan’s stewardship itself. “In every election they do stuff like this. They say they’re helping out, but I don’t think these stalls will be here after voting day,” said Semra, 72, who supports the ruling Justice and Development (AK) party. “I still appreciate the help.”

Only half of the advertised goods are available at the Taksim stand, but about 3,000 people a day have been visiting. The initiative is not just serving Erdoğan’s base, working-class AKP voters: Syrians and Afghans also lined up to buy the fresh produce that has become a luxury for many. Several people fretted over pre-weighed bags of spinach, worried about the two or three lira (27p to 41p) differences in price.

For the first time, the AKP party is facing an embarrassing prospect: losing control of several cities, including Istanbul and Ankara. One of the more reliable opinion polls puts the main opposition Republican People’s party (CHP) candidate, Mansur Yavaş, at least five points ahead in Ankara’s mayoral contest and the race is tight in other cities.

Even in Rize, an AKP stronghold on the Black Sea, there is growing awareness that government policy has contributed to inflation and unemployment. “I used to buy kilos of peppers to stuff,” said Nuri Guler, a retired tea factory worker. “But now I can only buy one at a time. So whatever they say on the television, we are not living in a rose garden.” Rather than vote for another party, Guler said he will probably just not vote.

Facebook Twitter Pinterest President Erdogan has blamed “food terrorists” for high prices. Photograph: Anadolu Agency/Getty Images

The opposition, hampered by a pro-government media, has been reinvigorated by the idea of wins in Ankara and Istanbul, which would be the first significant check on Erdoğan’s consolidation of power since he became prime minister in 2003. “Losing Ankara or Istanbul would be a big psychological blow to Erdoğan,” said Kimberly Guiler, a research fellow at the Harvard Kennedy School of Government’s Middle East Initiative. “It would chip away at his credibility. But so will removing any opposition candidates from posts they win, which has happened before and the interior ministry has threatened could happen again.”

Erdoğan has made every effort to ensure his party is not displaced this weekend. In Istanbul, the mayoral candidate is his right-hand man, ex-prime minister Binali Yıldırım. The president has toured the country for weeks, speaking up to eight times a day at rallies marked by divisive rhetoric. “[The elections are] a matter of survival against those who want to divide this country and tear it to pieces,” he told supporters this month in Istanbul’s Eyüp Sultan district..

Erdoğan has also earned a rebuke from New Zealand’s prime minister Jacinda Ardern for airing footage from the Christchurch mosque shooting and Greek prime minister Alexis Tsipras accused Turkey of forcing his helicopter to reduce its altitude after its flight path was disturbed by Turkish jets, inflaming tensions between the two countries.

“Turkey’s electorate is very polarised along ethnic, sectarian and ideological fault lines,” said Fadi Hakura, head of the Turkey project at Chatham House, the international affairs thinktank. “Attacking foreign countries and entities is an effective diversion tactic. It pulls focus away from the economy.”

Opposition candidates are worried about electoral roll irregularities, such as first-time voters supposedly aged 165 and 1,000 people all being listed as living in the same apartment – proof, they say, that the AKP is preparing to massage the results.

“If the government starts making the votes up, they won’t need to appeal to or care about dissatisfaction in the base,” said Hüda Kaya, a People’s Democratic Party (HDP) member of parliament for Istanbul. “That’s not populist tactics any more. It’s the stage that comes next.”