NEW YORK — For Recep Tayyip Erdogan, Turkey’s embattled prime minister, a win in Sunday’s local elections will be a Pyrrhic victory. While his Justice and Development Party, or A.K.P., will likely retain a majority of municipalities, Turkey as a whole, particularly as an international player, has lost.

Mr. Erdogan’s decade-plus grip on power has been weakened by anti-government protests, corruption allegations, and an ugly confrontation with the powerful and admired Muslim religious leader Fethullah Gulen. In a desperate effort to prevent any further hemorrhaging of his power, Mr. Erdogan has abandoned the ambitious foreign policy that was the basis for Turkey’s regional resurgence in recent years and has resorted to attacking his enemies. The prime minister is now so fixated on his own political survival that he recently attempted, in vain, to shut down Twitter across the country.

It’s a far cry from 2003, when Mr. Erdogan ascended to the premiership and announced a determined and democratic agenda to strengthen Turkey’s economic and global standing.

I visited him soon afterward in Turkey’s capital, Ankara. He told me then, “There are approximately 72 million people in this country — and I represent each and every one.” To represent everyone, he pushed for the passage of laws that granted increased freedoms to Turkey’s minorities, particularly the Kurds. He implemented economic policies to increase foreign investment. He reached out to far-flung capitals in Asia, Africa, Latin America and the Middle East, opening more than a dozen embassies and many new markets. He even secured a rotating seat for Turkey on the United Nations Security Council in 2009 and made contributions to Washington’s “war on terror.”