* Turkey a key U.S. ally in changing Middle East
* Differences over Israel, Syria strain relationship
* Closer Turkish ties with Egypt seen forming new axis
WASHINGTON/ISTANBUL, Dec 12 (Reuters) - With its caustic rhetoric on Israel and its gold-for-gas trade with Iran, Turkey is not the deferential U.S. ally it once was as it carves out a growing role in the fast-changing politics of the Middle East.
The collapse of its ties with the Jewish state have put paid to U.S. hopes it could be a broker in the Arab-Israeli conflict, while its gold sales to Iran have provided a financial lifeline to a government meant to be under the choke of U.S. sanctions.
Yet despite the strains, the relationship between Washington and Ankara is arguably more important than ever.
Seeking to rebuild ties with the Muslim world after the invasion of Iraq and war in Afghanistan, Washington needs all the allies it can get as it navigates the swirling political currents of the Middle East.
Turkey, too, needs friends. Its accession negotiations with the European Union have stalled, while relations with key energy partner Russia are strained over Syria. Turks joke that Foreign Minister Ahmet Davutoglu's much vaunted "zero problems with the neighbours" policy has turned into "zero neighbours".
In some senses, Washington is the only game in town.
"They both need each other," said Hayat Alvi, lecturer in Middle Eastern politics at the U.S. Naval War College.
"Turkey and the U.S. will have their differences, especially about the Israeli-Palestinian conflict, but that does not mean their relationship, however hot and cold it runs, will smash into a brick wall and shatter permanently."
When Barack Obama chose Turkey as his first Muslim nation to visit as U.S. President four years ago, he had high hopes that the secular democracy could help bridge the divide between America and the Islamic world.
From the stalled Middle East peace process to Iran's nuclear programme, Washington saw Turkey as a vital ally, an influential broker in a troubled region with common interests ranging from energy security to counter-terrorism.
Turkey, meanwhile, saw Obama's visit as overdue recognition for its efforts to mediate between Israel and Syria, to bring warring Palestinian factions together, and to patch up differences between Pakistan and Afghanistan. An endorsement, in short, of its newly assertive foreign policy.
Four years on, the world has changed.
The Arab Spring has redrawn the political map of the Middle East and Turkey has tried to bolster its influence.
Quick to champion the pro-democracy uprisings which saw decades-old dictatorships unseated in Tunisia, Libya and Egypt, it has become one of Syrian President Bashar al-Assad's bitterest enemies and grown openly critical of U.S. reluctance to intervene in a war that risks spilling onto its soil.
Once Israel's only Muslim ally, its relations with the Jewish state have also collapsed and, with them, the role Washington had hoped Turkey might play as a credible broker.
"Our relations with Israel are the lynchpin of the role Turkey can play in this region," said Faruk Logoglu, former Turkish ambassador to Washington and vice chairman of the main opposition Republican People's Party (CHP).
"When the state of relations with Israel is as it is now, we are out of the Middle East peace process, out of the Middle East equation, we are just a party to the conflict," he said.
"Turkey probably created a still unstated disappointment in many circles in Washington for really failing to play the leadership role a lot of people thought it could."
Flanked by the EU to the west, Syria, Iraq and Iran to the east and Russia to the north, Turkey's location makes it a vital listening post on a troubled region. When it comes to military and intelligence cooperation, officials on both sides say its relationship with the United States has rarely been stronger.
Turkish support and bases have proved vital, for example, to U.S. forces in Afghanistan, while Turkey hosts a NATO radar system, operated by U.S. forces, in its eastern province of Malatya to help defend against any regional threat from Iran.
It has always been a prickly relationship, driven more by a mutual need for intelligence than any deep cultural affinity.
Prime Minister Tayyip Erdogan's AK Party, made up of former Islamists, conservatives and pro-business liberals, is wary of being viewed as a U.S. puppet. His populist rhetoric, sometimes appearing at odds with U.S. interests, is aimed at a home crowd suspicious of Washington's influence.
The most striking recent example was his branding of Israel as a "terrorist state" during fighting in the Gaza Strip last month, comments which earned a swift rebuke from Washington but which were largely dismissed by diplomats as another example of him playing to the gallery.
Ties between Israel and Turkey, once Israel's only Muslim ally, crumbled after Israeli marines stormed a ship in 2010 to enforce a naval blockade of the Palestinian-run Gaza Strip. Nine Turks were killed, Israel's ambassador was expelled from Ankara, and military cooperation was frozen.Turkey demands an apology.
It was not what Obama had hoped for.
"Turkey has a long history of being an ally and a friend of both Israel and its neighbours. And so it can occupy a unique position in trying to resolve some of these differences," the U.S. president said during his 2009 visit to Ankara.
Both sides talk down their differences and have come through trouble spots before, not least when Turkey refused to let U.S. forces use its territory as a springboard for the 2003 invasion of Iraq or when it voted against U.N. sanctions on Iran in 2010.
Erdogan has voiced frustration at the idea that Turkey, heavily dependent on imported energy, might need to further cut its oil and gas imports from Iran to comply with U.S. sanctions meant to choke funding for Tehran's disputed nuclear programme.
Turkey has won waivers by trimming its Iranian oil purchases but, frozen out of the global banking system, Tehran has sharply increased its purchases of gold bullion from Turkey as payment for gas imports, raising Washington's concern.
An irritant, maybe, but not one that officials see as jeopardising the wider relationship.
"I don't think there's ice in the relationship. We have extensive cooperation with the United States in every field from foreign policy and counter-terrorism to trade and energy security," said a Turkish government official.
"In any healthy relationship you don't see eye to eye on every topic, and you don't hide the truth from your partner."
The strength of Turkey's relationship with the United States will face at least two major tests in the months and years ahead. The first will be its role in fostering stability in a post-Assad Syria, the second its ability to re-establish itself as a useful contributor to the Middle East peace process.
Syria has already proved a stumbling block.
Turkish officials complain that while Washington encouraged Turkish support for the Syrian opposition in the early days of the revolt against Assad, it has since left Ankara to manage the consequences alone, including an influx of more than 130,000 refugees and mortar shells and gunfire spilling over the border.
"There is a sense of disappointment over the lack of U.S. action in Syria, and I think that's understandable," said former U.S. ambassador to Turkey James Jeffrey, now with the Washington Institute on Near East Affairs.
"Assad will almost certainly not go without a fight and quite possibly another push from the U.S. such as a no-fly zone or other action."
With little sign of a thaw in the standoff with Israel, Turkey's ability to influence the Arab-Israeli conflict may lie more in its blossoming relationship with Egypt, whose new Islamist President Mohamed Mursi was praised by Obama for helping broker a ceasefire in Gaza last month.
Ankara is sensitive to suggestions that its role as peacemaker is being eclipsed by Cairo. Erdogan said Turkey played an "influential role" in reaching last month's peace deal, while Davutoglu has said Egypt and Turkey are not "competitors for leadership in the region".
Turkey has moved to strengthen ties with Mursi. Erdogan, government ministers and business leaders have visited Cairo, though how quickly that relationship will be able to develop given Egypt's deepening political crisis remains to be seen.
"There is a clear shift in how Ankara views its relationship with Cairo, there is a willingness to move towards closer cooperation, to create an Egyptian-Turkish axis," said Sinan Ulgen of the Centre for Economic and Foreign Policy Studies.
"This could be seen by some of the actors in the region as a Sunni alliance, a perception that needs to be taken into consideration," he said.
The bottom line is that Washington may simply have to get used to a Turkey that increasingly walks its own path and that, while mindful of U.S. interests, is unafraid to challenge them.
"For decades, American leaders... proclaimed democratic Turkey as a NATO, pro-Israeli bastion in the Middle East even as they knew Turkish foreign and security policy was in the hands of its military," wrote author and geopolitics expert Robert Kaplan in his book "The Revenge of Geography."
"Finally, in the early 21st century, Turkey... emerged as truly politically, economically and culturally democratic... and the result was a relatively anti-American, anti-Israeli Turkey."