By Kim Ghattas
BBC News, Washington
Mr Obama visited Mr Erdogan in Turkey earlier this year
When President Barack Obama meets Turkey's Prime Minister Recep Tayyip Erdogan in Washington on Monday, the talks will require an interesting balancing act to mirror the one Mr Erdogan himself seems to have been attempting.
At the White House, Mr Obama will sit down with a man who leads a country that is a key strategic and military ally of the US in a difficult region.
But he is also someone who has also called Iran's President Mahmoud Ahmadinejad "a good friend", has been cozying up to Sudan, and just excluded Israel from an annual military joint exercise that has been held with Nato and the US since the mid-1990s.
The US president, who has been seeking to improve America's image in the Muslim world, would probably have expected Turkey, a traditionally moderate, secular country and Nato member, to be one of his bridges to the rest of the Muslim word.
Instead, when he visited Turkey in April he found a country that under the leadership of Mr Erdogan and his Islamist-inspired AK party has seen a rise in anti-Western rhetoric and "nationalism imbued with Islamism", according to Soner Cagaptay, director of the Turkish Research programme at the Washington Institute for Near East Policy.
The US is concerned about Turkey's close ties to Iran
Although Turks have a much more favourable view of Mr Obama than they did of President George W Bush, only 14% of Turks have a positive view of the US - the lowest rating among 25 countries polled by the Pew Research Center this spring.
Combined with the changing political attitudes in Turkey, this is likely, in turn, to drive changes in the country's world view.
Some observers are worried that Turkey, frustrated by its stalled EU accession drive among other things, is seeking to recalibrate its foreign policy, not just by moving closer to the Muslim world but also by turning away from the West.
Last week, Turkey's Foreign Minister Ahmet Davutoglu rejected criticism of his country's improving ties with countries like Iran. He told the BBC that his country was attempting to have "zero-problem" with its neighbours.
This approach has allowed Turkey to rise as a considerable regional power and, until recently, this gave Ankara the ability to mediate between West and East, and between countries like Israel and Syria.
I think that we are very confident that Turkey remains a close partner of ours and a great friend and partner of Western Europe
Assistant US secretary of state for Europe and Eurasia
But recent developments like Turkey's hosting of Sudan's Vice-President Ali Osman Taha are a source of growing concern and raise doubts about the balancing act that Turkey is attempting.
As it grows closer to countries like Syria, it is alienating Israel, and while it defends Iran's nuclear program, it raises alarm bells in Washington.
Mr Obama is likely to be firm in expressing displeasure about the exclusion of Israel from the military exercise or his worry about the rise of anti-Western sentiments in Turkey.
But he may also seek to explore whether Washington can still reap any benefits from Turkey's improving ties with some of Washington's foes and its ability to talk to them, in particular Iran.
But the US wants Turkey to use its ties with Tehran to deliver tough messages, not just sign gas and trade deals, which Mr Erdogan did when he visited Iran last month.
Mostly Mr Obama will want to make sure that Turkey is not moving away from the West, so any criticism will be carefully phrased to avoid tension.
This is also because Turkey remains an important military ally that is home to US military bases which will be key during the US troop withdrawal next year from Iraq. Turkey also has 1,700 troops in Afghanistan.
So in public, the US administration insists it is not worried about the developing trends in Turkey.
"I think that Turkey was and remains a country with very close ties to the West and certainly to us," said Philip Gordon, the assistant US secretary of state for Europe and Eurasia, on a trip to Turkey last month.
"We are not surprised or worried by, as I said, Turkey's engagement and interest in the East.
"I think that we are very confident that Turkey remains a close partner of ours and a great friend and partner of Western Europe."
But speaking at a conference last year, before becoming an Obama administration official, Mr Gordon said that while Turkey was still a stable partner, "current trends augur that it could just as easily become a more nationalist country that resents its rejection from the EU and isolates itself from the West".
He concluded by advising the next administration, of which he was soon to become part, that it "should make sure that Turkey stays on the right path, because it would be sad to discuss four years from now why we lost a valued ally".
Since that conference, the situation has only deteriorated, so it is most likely that Mr Gordon is still concerned with making sure that Turkey "stays on the right path".