Amid the upheaval of the Arab revolutions, states both near and far are competing for influence in the region. One country that sees its chance is Iran, long opposed to the old Arab order. Another is Turkey, perhaps Tehran's ultimate rival in the region. But the last few weeks have seen an unexpected new actor, although one with a long record in the Middle East -- France.
Relations between Ankara and Paris are far from smooth. Turkey sees French president Nicolas Sarkozy as hostile to its interests -- he is against Turkish membership of the EU and paid only a brief, grudging visit to the country in his current capacity as president of the G20.
More importantly the two governments have been arm-wrestling over Libya and the Arab spring.
The AKP, Turkey's ruling party, was quick to call for the departure of Hosni Mubarak, Egypt's now ex-president. That position pleased the west -- particularly the US, which made clear it expected Turkey to take a consistent, pro-reform stance on the Middle East. But such consistency was not to be.
Partly because of commercial interests in Libya -- where many Turkish construction companies do business -- Ankara chose to stay aloof as the conflict in that country exploded, deciding just to watch and see how events unfolded.
When there was talk of NATO intervening, Tayyip Erdogan, Turkey's prime minister, roared: `What business has NATO in Libya?`.
This came as an unwelcome surprise to Washington. Paris, by contrast, saw it as an opportunity to sidetrack Turkey`s aspirations to become a bigger player in the region.
As soon as the UN Security Council authorized military intervention in Libya, France lost no time in arranging an emergency 22 country summit. Turkey was not on the guest list. The Turkish government, furious at being left out, immediately made a sharp U-turn and tried to bring the issue to the table at NATO. Erdogan and his ministers now argued that command and control for the entire Libya mission should be under NATO and decided to send warships and planes for the international operation.
That wasn't at all to the liking of France, which is traditionally allergic to using NATO and would have preferred much more autonomy. But going through NATO gave Turkey a veto on decision-making -- which probably helped Erdogan overcome his previous objections about involving the western alliance in a military action in the Arab world.
Washington has been in favor of a lead NATO role from the beginning. The Obama administration knew very well that the US could not financially and politically afford another war in a Muslim country. So it has been keen to avoid characterizing the action as a war and even keener on other countries taking over the lead.
The discussions within NATO boiled down to a fight between France -- which would like to have a much more active role in the region -- and Turkey, which does not want to share the stage with any other outside powers and has been cultivating ties for quite some time.
In the end France wasn't able to set up a parallel structure to NATO to control the operation -- a failure that helped the Turkish government to market the outcome domestically as a victory over France.
The fight isn't over. Sarkozy looks like he's running an aggressive foreign policy in the Middle East and elsewhere -- the French military is also currently fighting in Ivory Coast -- to revive his lagging support ahead of presidential elections next year.
Sarkozy has also been manipulating anti-Turkey feelings in France for his own political gain for some time now. He has often asserted that that Turkey -- "Asia minor" as he calls it -- does not belong in Europe. Thanks to him and other hostile EU countries, Turkish public support for joining the Union has fallen considerably.
Meanwhile Turkey has been running an inconsistent, opportunistic policy towards the Middle East under foreign minister Ahmet Davutoglu. The latest uprisings in the region -- and France's emergence as a new rival -- have cast a revealing light on Ankara's twisting and turning.
The AKP has differed with its western allies on many big issues -- like Iran, Israel, missile defence and Sudan -- partly for the sake of demonstrating that Turkey's policy is independent. But on Libya, it eventually had to support Washington and sign off on NATO's role for fear of losing ground to France.
In the end, realpolitik pushed Turkey back to its traditional alliances on Libya. But on the broader Middle East it is still in desperate need of recalibrating its foreign policy.
Follow Elcin Poyrazlar on Twitter: www.twitter.com/elcinpoyrazlar