ANKARA (Reuters) - Turkey remains firmly anchored in the West and its partnership with the United States has never been stronger even as the sides remain split on Israel's war in Gaza, U.S. Ambassador to Ankara Jeff Flake told Reuters.

Flake, set to leave his post this autumn, said Turkey's endorsement of NATO enlargement and a deal to sell U.S. F-16s signalled Ankara's tilt to the West this year and set the stage for lasting momentum in trade and investment.

"The strategic partnership has never been stronger and we're in a good place," Flake, 61, said in the interview at his residence in Ankara.

A former Republican senator nominated by Democratic President Joe Biden, Flake's posting began in early 2022 and has been dominated by fallout from Russia's invasion of Ukraine, which happened six weeks after he arrived in Turkey.

Washington has pressed Ankara to clamp down on any evasions of its sanctions on Moscow, and also to endorse NATO enlargement, which resolved in January with Turkey's blessing of Sweden's membership after a 20-month delay.

Flake said that despite Turkey's strong economic, commercial and energy ties with Russia, the war in Ukraine highlighted its commitment to NATO and the West.

Turkey "has been pitch perfect in its support for Ukraine's territorial integrity and sovereignty," Flake said, citing its halting Russian warships transiting to the Black Sea and its supplying drones to Kyiv.

He added that bipartisan sentiment toward Turkey in the U.S. Congress had turned positive this year, and that would continue irrespective of the U.S. election outcome in November.

"They're firmly anchored in the West."

ISRAEL-GAZA SPLIT

The main strains on U.S.-Turkey ties in recent years are the U.S. alliance with Syrian Kurds that Turkey deems terrorists, and over Turkey's purchase of Russian S-400 defences that prompted U.S. sanctions and removal from a F-35 jet programme.

The latest divergence is over the Gaza war, for which Turkish President Tayyip Erdogan has sharply criticised what he calls Israeli war crimes and U.S. support for the operation against Palestinian militant group Hamas.

The U.S. envoy said that while Erdogan's planned visit with Biden at the White House last month was cancelled due to scheduling problems, it also happened at a time that the situation in Gaza cast a "tough political backdrop".

"Obviously there's going to be differences with the Gaza situation, that's a tough one," he said.

But Flake added that Ankara's close ties with Hamas political leaders provided a valuable conduit during the conflict and in ceasefire talks, and that Washington sometimes asks it to deliver messages to them.

A North Atlantic Treaty Organization (NATO) leaders meeting in Washington next month presents an opportunity for a Biden-Erdogan meeting given "there's some desire on both sides," he said.

RUSSIAN-TURKISH TIES

In his 2-1/2 years in Turkey, Flake sought to use his ties with U.S. Congress to overcome some members' concerns over Turkey's commitment to the West and over Erdogan's record on human rights.

The sale of F-16 jets and modernisation kits to Turkey - just after the endorsement of Sweden's NATO bid - shows growing trust between the sides, Flake said, and helped "unlock" cooperation in manufacturing and other direct investments.

Flake's comments come after Ankara said last week it could consider joining the BRICS group of nations - comprising Brazil, Russia, India, China, South Africa, and others.

Foreign Minister Hakan Fidan met President Vladimir Putin in Russia this week and attended a BRICS meeting. Fidan was later cited by state media as saying that Turkish-Russian ties "are truly going fantastically well."

Putin said on Tuesday Erdogan would attend a Shanghai Cooperation Organisation summit in July and he hoped to meet him there.

Flake said that while he hoped Turkey would not join BRICS, such a move would not change its alignment with the West.

"I think that they realize that Russia's economy is turning to a wartime economy. There's not much future there, particularly with the sanctions that have been imposed by the West," he said, adding Washington was working with Ankara to ease its energy reliance on Russia.

(Reporting by Jonathan Spicer and Tuvan Gumrukcu, Editing by William Maclean)

By Jonathan Spicer and Tuvan Gumrukcu