By Jonathan Marcus
BBC diplomatic correspondent, Istanbul
The US had feared Turkey was facing too much towards the East
Not so long ago the question of "who lost Turkey?" seemed to dominate US think tank discussions and conferences.
Turkey's refusal to allow US troops to use its territory to open a second front against Saddam Hussein provoked the worst crisis in relations between Ankara and Washington that many commentators could remember.
Worse, the arrival into power of the Justice and Development Party (the AKP) with its Islamist roots, which then embarked upon a new foreign policy of outreach towards the Middle East, seemed to confirm the fears of many in Washington.
Turkey, they felt, was inexorably being drawn back into the Middle East and Asia and away from its long-standing anchorage in Nato and the West.
With the US presidential election fast approaching, and with the multiplicity of problems in the Middle East set to be at the top of the next administration's agenda, I came to Turkey to try to answer the question - was this staunch Cold War ally being lost to the West?
Surely things were more complicated? Was Turkey's new orientation being misunderstood by some in Washington? And what did Turkey itself want from the next US administration?
My first port of call was a pavilion in the grounds of the last sultan's palace on the edge of the Bosphorus. It is now the Turkish prime minister's Istanbul office.
There I met Ambassador Ahmet Davutoglu, a quietly spoken academic who is widely acknowledged as the architect of the Turkish government's new foreign policy.
His 2001 book, entitled Strategic Depth, sought to chart a new course for Turkey in the aftermath of the Cold War.
"There was a need to reinterpret the geographical and historical context of Turkey," he told me.
"The aim was to reintegrate the country into its surrounding region."
Nonetheless, he was at pains to point out that these new relationships were compatible with Turkey's long-standing Atlanticist and European tilt.
"If you have more influence in your own hinterland, you will be a more meaningful contributor to the EU or to Nato," he told me.
"Turkey's diplomatic power," he said, "is an asset for our western orientation."
There is no doubting the extent to which Turkey has played upon its extraordinary geographical position to develop new diplomatic and trading links.
Today it is as friendly with Syria as it is with Israel. It has close ties with Iran and Saudi Arabia. It has good relations with both Palestinian factions, Hamas and Fatah.
It has developed a strong relationship with Russia and it maintains its strong links with the US and western Europe.
Mr Davutoglu is now the Turkish prime minister's chief foreign policy adviser.
Turkey, he told me, was looking to play an ever-greater role in the Middle East, and despite all of the ups and downs between Ankara and Washington, ties between them were firm.
The US views the Kurdish separatist PKK as a security threat
"The Turkish-American relationship is not an ordinary relationship," he told me.
"It is well-established, it is well-institutionalised, and very sophisticated. Whoever comes to power in Washington, that institutionalised framework will set the basic parameters for the new president."
It is certainly true that the Bush administration's decision to view the Kurdish separatist organisation, the PKK, as a threat to US security interests as well as those of Turkey has gone some way to restoring trust between the two governments.
Iraq though, and especially the circumstances of any US troop withdrawal by a new US president, is a major concern for the Turkish authorities.
Veteran commentator Professor Iltar Turan told me that Turkey fears Iraq might simply break up if there is a too hasty US withdrawal; it might degenerate into full-scale civil war.
"Iraq needs to be integrated better," he told me, "before a full US withdrawal can be entertained."
There is also a strong sense here that Turkey's diplomatic initiatives have not been fully understood or welcomed in Washington.
The Bush administration has been at best indifferent to Turkey's major initiative in the region - its efforts to broker a peace deal between Israel and Syria.
Four rounds of indirect talks have been held in Istanbul, mediated by Mr Davutoglu himself.
He refused to touch on any detail, such were the sensitivities, but, he assured me, the progress had been remarkable.
In Ankara, I went to see one of the AKP's most prominent foreign policy experts, Suat Kiniklioglu, an MP and spokesman for the Foreign Affairs Committee.
On Syria, he said that the US administration "had been very distant".
But he believed that the US was belatedly coming around, though he acknowledged that Turkey's ties with Iran were something that the Bush administration would not favour.
"We expect and hope that the new US administration will be more supportive of Turkey. But you know," he mused, "we will have to see - there are two very different candidates and there could be two very different Americas, depending upon who will win in November."
So who do the Turks want to see as the next US president?
Not surprisingly, opinions differ.
Prof Turan told me that Senator Barack Obama's inexperience in foreign policy worries many Turks, along with some of the things he has said on issues that matter greatly to Turkey.
"Many of us," Prof Turan told me, "think that the election of Senator John McCain who is familiar with security matters - and the US-Turkish relationship is to a large extent based on security concerns - is better."
The leading writer and academic Soli Ozel took a different view. He told me that he favours Mr Obama.
"I think a McCain presidency - especially with Ms Palin as vice-president - would be nothing short of catastrophic," he said.
"A white man of 72 years of age who is a Republican - I don't think that is what the world looks to in order to mend relations with America around the globe, so I think that whatever is going to be good for the world, ought to be necessarily good for Turkey."
Official spokesmen obviously do not want to be drawn into the political fray.
But Mr Davutoglu told me that Turkey wanted greater US attention to the crisis around its borders.
"The Turkish foreign agenda is like the United Nation's agenda", he argues.
"What do you have on UN agenda today? The Palestinian question, the Iraqi question, the Iranian question, the Caucasian question, the Kosovo question - they are all on Turkish foreign policy agenda too," he said.
"Without Turkish involvement," he went on, "it is going to be difficult to solve any of these crises. So Turkish strength, in terms of hard power, of soft power, in terms of economic relations, is an asset for any American administration."
To get the perspective of someone with a foot in both countries, I went to see Soner Cagaptay of the Washington Institute for Near East Policy.
He heads their Turkish research programme and is currently in Istanbul teaching for three months.
Turkey can look elsewhere if it is rejected by the EU
"Turkey policy in Washington," he says, "has always been a derivative of other policies - of Iraq policy, of Afghanistan policy and maybe now even of Georgia policy.
"Turkey is important as a secondary partner, not as a primary partner, with which the US envisions its big foreign policy debate."
Whoever takes over in Washington, he says, needs to take a view of Turkey from 30,000 feet up; to realise that it is important when the US plans policies, not only when it is implementing them.
"This," he argues, "would probably give the Turks the sense of importance they are trying to find in the region, and it would be one way for the next US president to counter Turkey's ongoing rapprochement with Russia and Iran."
In my week shuttling between Istanbul and Ankara, it seemed clear that Turkey was proud and confident of its considerable diplomatic achievements .
It wants these to be seen as an asset by the West too.
Turkey's new regional aspirations are not to be seen as being in conflict with its anchorage in the western camp.
But if the West rejects Turkey - and by this Turkish commentators generally mean the European Union - then Turkey does have other cards to play.
No wonder then that the EU's ambivalence towards Turkey creates so much unease in Washington.