ISTANBUL (Reuters) - A dispute between Turkey and the United States over control of a north Syrian town has put the NATO allies on opposing sides of the conflict’s front line, deepening a diplomatic rift ahead of a visit to Turkey by U.S. Secretary of State Rex Tillerson.

FILE PHOTO: American army vehicles drive north of Manbij city, in Aleppo Governorate, Syria March 9, 2017. REUTERS/Rodi Said/File Photo

This week’s talks, already challenging given disagreements over President Tayyip Erdogan’s crackdown after a failed 2016 coup, the detention of U.S. consulate staff and citizens, and the trial of a Turkish bank executive for evading U.S. sanctions on Iran, have been given added edge by the dispute over Syria.

Turkish and U.S. troops, deployed alongside local fighters, have carved out rival areas of influence on Syria’s northern border. To Ankara’s fury, Washington allied itself with a force led by the Kurdish YPG, a militia which Turkey says is commanded by the same leaders overseeing an insurgency in its southeast.

The dispute has come to a head over the Syrian town of Manbij, where Turkey has threatened to drive out a YPG-led force and warned the United States - which has troops there - not to get in the way.

“This is what we have to say to all our allies: don’t get in between us and terrorist organizations, or we will not be responsible for the unwanted consequences,” Erdogan said last month, days before launching a military offensive against the YPG in the northwestern Syrian region of Afrin.

Turkey would turn its attention to Manbij, about 100 km (60 miles) east of Afrin, “as soon as possible”, he said.

But Washington says it has no plans to withdraw its soldiers from Manbij, and two U.S. commanders visited the town last week to reinforce that message.

It has also warned that Turkey’s air and ground offensive in Afrin risks exacerbating a humanitarian crisis in Syria and disrupting one of the few corners of the country that had remained stable through seven years of civil war.

In a blunt but possibly understated assessment of Tillerson’s visit, a U.S. State Department official said Washington expected “a difficult conversation” in Ankara.

For Turkey, the dispute has pushed relations with the United States to breaking point.

“We will discuss these issues during Tillerson’s visit, and our ties are at a very critical stage,” Foreign Minister Mevlut Cavusoglu said on Monday. “Either we will improve our ties, or they will completely deteriorate.”

“GUNG-HO” MILITARY

As the grievances between Washington and Ankara have escalated, Turkey has built bridges with rival powers Russia and Iran - even though their support has put Syria’s President Bashar al-Assad in the ascendancy while Turkey still backs the weakened rebels seeking his downfall.

The three countries agreed a so far ineffectual plan to wind down the fighting between the Syrian army, which is supported by Russian air power and Iran-backed militias, and jihadist fighters and Turkish-backed rebels.

Turkey says it also won agreement to launch its Afrin operation from Russia, which controls most of the air space in western Syria.

In contrast, it says the United States has yet to honor several pledges: for Washington to stop arming the YPG, to take back those arms after Islamic State was defeated in Syria, and to pull back YPG forces from Manbij.

Last week’s visit to Manbij by U.S. military commanders was a short-sighted and thoughtless “military gung-ho gesture”, according to Erdogan’s senior foreign policy adviser, Gulnur Aybet.

“It is not helpful, at a time when the United States and Turkey are trying to find common ground ... for U.S. generals in the field to undertake a flippant and provocative display in Manbij next to the YPG,” she told Reuters.

Relations with the United States were “fragile and frustrating because pledges have been unfulfilled and there is a lack of coherence between the White House and the military”, Aybet said.

U.S. VIEWED UNFAVORABLY

Erdogan has also said Turkey will “strangle” a force which the United States plans to develop in the large sweep of northern Syria which the YPG and its allies currently control, including more than 400 km (250 miles) of the border with Turkey.

His tough language, a year before presidential and parliamentary elections, resonates in a country where 83 percent of people view the United States unfavorably, according to a poll published on Monday.

The poll for the Center for American Progress also found that 46 percent of Turks think their country should do more to confront the United States, compared with 37 percent who believe it should maintain the alliance.

That sentiment has underpinned Erdogan’s unyielding response to other disputes with Washington.

He has dismissed criticism of Turkey’s crackdown since the failed July 2016 coup, in which 250 people were killed, saying the response is justified by the security challenges Turkey faces.

The president has also said the U.S. court conviction of an executive of Turkey’s state-owned Halkbank for evading Iran sanctions was a “political coup attempt” which showed the U.S.-Turkish partnership was eroding.

In October he accused the U.S. consulate in Istanbul of sheltering an employee with links to U.S.-based cleric Fethullah Gulen, blamed by Ankara for last year’s failed coup. Turkey has sought the extradition of Gulen, who has denied any link to the coup attempt.

Turkey’s detention of two locally employed U.S. consulate workers - without providing evidence, according to Washington - led to the two countries suspending visa services. Even when services were resumed, they disagreed publicly over what assurances had been made to resolve their differences.

“The U.S.-Turkey alliance can no longer be taken for granted,” Ozgur Unluhisarcikli of the German Marshall Fund of the United States, which promotes transatlantic cooperation, wrote in a report published ahead of Tillerson’s trip.

“That this relationship has endured several stress tests in the past is no guarantee that it will survive this one”.

(THis story corrects spelling of adviser’s name in paragraph 16)