When the uprising broke out in Libya, Turkey first dismissed the idea of sanctions or any NATO military action, denouncing what it called Western designs on Libya's oil.
Later, Turkey reversed that decision after the United Nations approved steps to protect civilians from Moammar Gadhafi.
Turkey's evolving responses to the war in Libya are just the latest indication of its goal to be a powerbroker on the world stage _ one that balances its alliances to Mideast leaders such as Gadhafi with calls for them to reform in the face of street revolts.
It was only last year that Prime Minister Recep Tayyip Erdogan demonstrated close ties to Libya by collecting a human rights award from Gadhafi. He has since spoken to Gadhafi several times by telephone, suggesting that he cede leadership to a figure who can pursue reconciliation, and Turkey agreed to a robust humanitarian role in NATO's mission in Libya.
As a NATO ally, Turkey has cultivated warm relations with countries such as Libya and Syria as part of a regional outreach that included nations with a history of enmity with the West.
Now this democracy led by devout Muslims is scrambling to preserve economic and other links to Mideast nations while urging their autocrats to meet the demands of protesters who want change.
The balancing act tests Turkey's avowed policy of "zero problems" with neighbors. It also raises questions about what drives Turkish intentions in the region: its growing Muslim identity, "realpolitik" interests such as trade and power, commitment to democratic reform, or some combination.
For instance, in February, the leaders of Turkey and Syria laid a foundation stone for a "friendship dam" that will provide cross-border irrigation and electricity.
"Turkey doesn't want to be viewed as a sort of de facto nation, a nation that just went along with every plan created by the West and NATO," said Cengiz Aktar, a political science professor at Bahcesehir University in Istanbul. "Turkey wants to make a difference in the region."
Even so, Aktar said Turkey's diplomatic heft has limits and noted: "Like everyone else, Turkey is running with the unfolding events."
Turkey's independent streak, symbolized by the blunt and sometimes combative populist statements of Erdogan, reflects the confidence of Turks who have largely shed their own record of chaos. Turkey will hold an election in June that is likely to return the governing Justice and Development Party to power for a third time since 2002.
Turks have their own problems, including free-speech worries, the grievances of the Kurdish minority and a stalled bid to join the European Union. But they draw Mideast admiration for their electoral vitality, a strong economy and their stature as a voice for Muslims that is unafraid to criticize Israel and the West. Even their television soap operas have regional fans.
"In some ways, Turkey's alliance system is falling apart. On the other hand, it seems likely that the sort of 'soft power' that Turkey represents is going to be effective regardless of who's in power," said Howard Eissenstat, an expert on Turkey at St. Lawrence University in Canton, New York.
"Turkey is increasingly convinced that European and American influence in the region is on the decline and that Turkey can pick up that role," said Eissenstat, who compared its Mideast cachet to the "love affair" of Western Europeans with the United States in the early years after World War II.
A poll released last month by TESEV, a Turkish research center, found that 66 percent of respondents in half a dozen Mideast nations thought Turkey can be a regional model, based on its Muslim identity, economy and democratic system. The survey of about 2,000 people had a margin of error of 2 percent and was conducted in August and September.
Yet Turkey, which spans the European and Asian continents, recognizes that its Western links elevate its international clout, just as the West recognizes Turkey's potential as a bridge to a region that was turbulent well before the revolts.
Erdogan's initial, contradictory response to the fighting in Libya fit a cycle of resistance and cooperation with France and other key NATO nations by Turkey, whose foreign agenda was overshadowed by its Western allies during the Cold War.
Turkey also objected to the 2009 candidacy for NATO's top job of Denmark's Anders Fogh Rasmussen, and rejected the idea of naming Iran as a threat in discussions on missile defense at a NATO summit last year.
"I think these contradictions and bumps are going to increase over time as regional considerations and maybe trans-Atlantic considerations clash," said Gulnur Aybet, a NATO and Turkey analyst at the University of Kent at Canterbury in Britain.
Aybet said Turkey wants to preserve traditional security ties, enhance its appeal to Muslims beyond its borders and have an independent hand in regional relations, free of ethnic or religious ties. From next month, for example, Turkish and Russian citizens will be able to travel to each other's countries without a visa, and trade between the two countries exceeded $25 billion last year.
Critics compare Turkey's ambivalence over military action in Libya to its case for intervention to protect Bosnia's Muslims from Serb forces in the 1990s. Raw emotion also shapes the views of Turks, who dominated the Middle East during the Ottoman Empire.
The prospect of military strikes in Libya initially reminded many of U.S.-led wars in Iraq and Afghanistan, and early British and French action recalled the ill-fated military campaign in the Suez crisis of the 1950s.
"Turkey is progressively perceived as a 'Western country of the Middle East,'" commentator Mehmet Ali Birand wrote in Turkey's Hurriyet Daily News.
That puts Turkey in the unique position of talking to all parties. The Turkish embassy in Tripoli is open, and so is the Turkish consulate in Benghazi, the opposition stronghold.
In addition to urging Gadhafi to step down, Erdogan has urged reform in telephone calls with Syrian President Bashar Assad, whose government promised change even as security forces cracked down on protesters, killing dozens.
Turkey also has sought to mediate in the Persian Gulf, where protests in Bahrain form a backdrop to tension between Iran and Saudi Arabia.
The Stratfor analysis group in Austin, Texas suggested Turkey, which has warm ties with Tehran, could check Iranian influence in line with U.S. interests, though it warned the extent of Turkish clout is unclear.
"There are so many unknowns," a Turkish government official said on condition of anonymity because of the sensitivity of the issues. "It is very difficult to make an assessment, and even a policy."
Erol Israfil in Istanbul contributed to this report.