Turkey and the United States on Monday endorsed a road map for the northern Syrian city of Manbij and underlined their mutual commitment to its implementation after a meeting of their foreign ministers in Washington, according to a joint statement.
Following the agreement, the powerful Syrian Kurdish militia, which has so antagonised Ankara, agreed to withdraw from the town on Turkey's southern border.
The Kurdish People's Protection Units (YPG) said in a statement it had decided to pull a final group of its military advisers out of Manbij, two years after leading a victorious offensive to rid the town of ISIS.
The road map, long sought by Turkey, comes at a time of strain in bilateral ties over wider Syria policy and over Washington's decision in December to move its embassy in Israel to Jerusalem.
Turkey has been infuriated by US support for the Kurdish YPG militia, which it views as a terrorist organisation, and has threatened to push its offensive in the Afrin region of northern Syria further east to Manbij - risking confrontation with US troops stationed there. Washington views the YPG as a key ally in the fight against ISIS.
At their talks in Washington, Turkish Foreign Minister Mevlut Cavusoglu and US Secretary of State Mike Pompeo also discussed co-operation in Syria, along with potential steps to improve security in Manbij, they said in a statement.
"They endorsed a road map to this end," the statement said.
The Pentagon has long feared that Manbij could become a flashpoint in Syria, with US-backed forces who cleared the city of ISIS fighters clashing with Turkish forces. That would put Washington in the unenviable position of either fighting a Nato ally or abandoning its proxy forces in Syria.
The statement did not explicitly spell out how Turkey and the US would resolve the Manbij issue or detail next steps in the so-called road map.
"The aim of this road map is the clearing of Manbij of all terror organisations and the permanent instatement of safety and stability," Mr Cavusoglu told a press conference in Washington.
"In the first step, the determination of parameters for common plans for the removal of YPG-PYD from Manbij — you can also call it PKK — will be determined."
The reference to the PKK was a jab at Washington. Ankara considers the YPG to be an arm of the PKK, which both the US and Turkey consider a terrorist group.
Mr Cavusoglu said Turkish and US units would together implement security and stability in Manbij, and the removal of all YPG organisations from Manbij would be completed.
"In the long term, this road map that will implemented in Manbij will be carried to other regions to implement security and stability in other regions in Syria. Meaning the co-operation will continue in other regions," he said.
The Syrian government, Kurdish militants, Syrian rebel groups, Turkey and the US all have a military presence in northern Syria.
Relations between Ankara and Washington have deteriorated due to a range of factors, including the sentencing in New York in May of a former Turkish state bank executive to 32 months in prison for taking part in an Iran sanctions-busting scheme, a case Turkey has called a political attack.
Turkey has also caused unease in Washington with its decision to buy S-400 surface-to-air missiles from Russia and drew criticism over its detention of a US Christian pastor, Andrew Brunson, on terrorism charges. He has denied the charges.
Also at issue is the potential sale of F-35 fighter jets to Ankara.
Last month, a US Senate committee floated a defence policy bill that included a measure that would prevent Turkey from purchasing Lockheed Martin-made F-35 Joint Strike Fighter jets.
Nato ally Turkey was also faulted for its agreement with Russia in December to buy the S-400 surface-to-air missile system.
The move to buy S-400s, which are incompatible with Nato systems, has unnerved Nato member countries, which are already wary of Moscow's military presence in the Middle East. This has prompted Nato officials to warn Turkey of unspecified consequences.
Turkey plans to buy 100 of the F-35 jets, and has had talks with Washington about the purchase of Patriot missiles that could be an alternative to the S-400 system.
A Capitol Hill source said that if the F-35 sales were derailed and not replaced by another buyer, each F-35 of the same model would increase in price by about $1 million (Dh3.67m) for the US and it allies.
Ankara wants the missile batteries to boost defence capabilities amid threats from Kurdish and Islamist militants at home and conflicts across its borders in Syria and Iraq.