ISTANBUL, TURKEY — Turkey's Islamist-leaning ruling party easily won municipal elections across most of the country Sunday but saw its overall margin of victory shrink and managed only a narrow win in Istanbul, the largest and most cosmopolitan city.
The vote, a week before a planned visit by President Obama, highlighted the ongoing struggle between secular-minded Turks and their more devout compatriots.
Turkey is overwhelmingly Muslim, but since its founding has observed a strict separation of mosque and state. A North Atlantic Treaty Organization ally, it is regarded as a bridge between the West and the rest of the Muslim world.
National elections are not due again for three more years, and midterm votes like this one are an important barometer of public sentiment.
Analysts said the results suggested that secularists, though lagging overall, were gaining ground, and that the economic slump was taking its toll. A crestfallen Prime Minister Recep Tayyip Erdogan said his Justice and Development Party, known as the AK Party, would have to "take lessons" from the outcome.
In the country as a whole, candidates from the AKP took the largest share of mayor's posts and local council seats, garnering about 40% of the vote, with the remainder split among smaller parties, according to unofficial returns.
But in Istanbul, the main secularist opposition party, the Republican People's Party, surged to a stronger-than-expected showing. With nearly 90% of the vote counted by early today, it had racked up about 38% to the AKP's 44%.
"It's different out in the countryside," said Zeynap Guler, a marketing executive in skintight leggings who was following late-night results with her friends in a chic Istanbul cafe. "Here we like to live as we please, dress as we please."
Many secularists are still bitter over the AKP's decisive 2007 victory in national elections. Opponents went to court last year to try to have the party outlawed for allegedly subverting Turkey's secular constitution.
Separately, nearly 150 people, including two retired generals, have been charged in a plot to overthrow Erdogan's government . The military sees itself as the guardian of the secular system created by modern Turkey's founding father, Kemal Ataturk.
The AKP's main platform has been economic development and joining the European Union. But over the last few months, unemployment has surged and the national currency, the lira, has slumped. AKP backers tend to blame the end to a five-year economic boom on the global downturn rather than the party.
"It hasn't been perfect; there are some negative aspects, but we are on the right course," said Sevida Yaman, a homemaker who was waiting to cast her ballot at a crowded polling place in central Istanbul. She wore a head scarf, the emblem of an observant Muslim woman.
But voter Saif Yilmaata said he had come to express his opposition to the AKP, which he accused of having an Islamist agenda. "The government we have now is close to a dictatorship," he said.
With a renewed mandate , Erdogan is expected to move ahead with measures including a rewrite of the 1982 constitution, which was essentially written by the military, and to pursue reforms of the Constitutional Court, the body that only narrowly rejected the bid to outlaw the AKP.