At the beginning of March, Turkish Prime Minister Recep Tayyip Erdogan spelled out his view of Nato-led intervention in Libya.
It would be absurd, unthinkable, he said. It should not even be discussed. Two weeks later he repeated that view. Nato intervention would be useless, he said, and would have dangerous consequences.
But this week, Turkish policy towards Libya appears to have done a complete U-turn. Criticising the French government for taking the lead role in air attacks on Col Gaddafi's forces, Turkey has insisted that command of the operation be handed over to Nato, and Nato alone. For this to happen, the agreement of Turkey - a Nato member since 1952 - is essential.
Five Turkish navy ships and a submarine have been despatched to help enforce the arms embargo against Libya. The Turkish parliament has approved sending more forces, including troops, if necessary.
So what's going on in Ankara?
Turkish Foreign Minister Ahmet Davutoglu explained the volte-face as a result of UN Security Council Resolution 1973, passed on 18 March, and the Arab League's support for a no-fly zone. We were against any unilateral Nato action, he said, but once these resolutions were passed, Turkey's stance could not remain the same.
But there is a lot more to Turkey's apparent flip-flop than that.
Turkey has pursued an ambitious new foreign policy under Mr Erdogan, with the aim of becoming a regional power. The policy relies on two strategies.
First, solving conflicts with its neighbours. Twenty years ago, Turkey was at daggers drawn with every country on its border. Today, it has friendly relations with all of them, except Armenia.
Second, allowing business ties to drive foreign policy. Turkish companies are among the most competitive in the region, and they have led the way in establishing a Turkish presence in Iran, Iraq, Syria, the former Soviet Union and the Balkans. Whenever the prime minister or president travel, they are accompanied by big business delegations. Visa-free travel has been agreed with Libya, Syria, Jordan and Lebanon. Free-trade zones are being negotiated.
This has meant cosying up to leaders like Muammar Gaddafi, Bashar al-Assad, Hosni Mubarak and Mahmoud Ahmadinejad. It has resulted in substantial Turkish investment in these countries, and tens of thousands of Turkish nationals working there.
So when the Arab uprisings began, Mr Erdogan was presented with a dilemma.
His political success in Turkey is partly due to his finely-tuned populist instincts. As a politician who has loudly stood up to Israel, he is something of a hero both among his largely Islamic constituency at home and among Arab populations elsewhere. So he wanted to do the popular thing by supporting the uprisings. But doing so put the profitable relationships his government had nurtured with the governments confronted by these uprisings at risk.
Tunisia happened too fast for anyone to react, and Turkey was left with the easy job of welcoming the new regime. Egypt was trickier. If Mr Erdogan called for Mr Mubarak to go, and he survived, there could be potential reprisals. The Turkish prime minister followed his instincts, told the Egyptian leader his time was up well before President Obama got round to it, and events vindicated him.
Libya was trickier still. There were 30,000 Turkish workers there. Col Gaddafi was less predictable. So the Turkish government kept its comments neutral while it organised a mass evacuation of its own and other foreign nationals.
Turkish officials say Mr Erdogan has called Col Gaddafi and his son Saif al-Islam several times to explore a negotiated end to the fighting. Libyan opposition leaders have been flown to Ankara for talks. Turkey says it was making progress when they were stopped by the start of French air attacks on Libyan ground forces. Just how much progress is not clear - the Turkish plan was to persuade Col Gaddafi to step aside and organise new elections, goals that never seemed very close.
Events in Bahrain, Yemen and especially Syria could provide further discomfort for Mr Erdogan. He has maintained conspicuously warm ties with the current governments in all three countries.
The tortuous path of Turkish policy has also been influenced by the general election scheduled in less than three months time, and Mr Erdogan's need to shore up his conservative Muslim base. Muslims in Turkey, like those all over the Middle East, have conflicting feelings about Libya. They have been clamouring for something to be done to help the Libyan opposition, but there is deep antipathy to Western intervention, and to any action that could result in Muslim civilians in Libya being killed.
Once the UN resolution was agreed, though, Turkey was always likely to want to play a role. It prides itself on being a responsible player in the UN and on its support for multilateral security operations. Turkey has 1,600 troops in Afghanistan and has regularly commanded the international force there.
It was also spurred on by seeing France take the lead. Relations between France and Turkey are badly strained over French objections to eventual Turkish membership of the European Union. There was outrage in Turkey over President Sarkozy's first official visit last month, when he stayed only six hours. There was further outrage when Turkey was not invited to the summit meeting on Libya that Mr Sarkozy convened after the UN vote.
French air attacks on Libyan ground forces were denounced by the Turkish Foreign Minister as going beyond what the UN had authorised. So when France objected to Nato taking command, Turkey instinctively pushed the other way.
Having agreed a Nato-led operation, though, Turkey is still insisting that cannot include attacks on ground forces, or attacks that put civilians at risk. Any future French, British or US sorties against Colonel Gaddafi's army may therefore have to be presented as being "outside" Nato's command.