ANKARA, Turkey — The United States and Turkey agreed Friday to open a formal dialogue to resolve their differences over a Kurdish militia in Syria, averting a near-collapse in relations but without mending any of the deep fissures keeping them apart.

Secretary of State Rex Tillerson, after marathon talks with Turkish President Recep Tayyip Erdogan and Foreign Minister Mevlut Cavusoglu, said a working group to tackle the differences would meet by mid-March.

Tillerson acknowledged how close the NATO allies had come to a breakdown in relations.

“We find ourselves in a bit of crisis point in the relationship,” he said at a news conference.

“We’re not going to act alone any longer,” he added. “We’re not going to be the U.S. doing one thing, and Turkey doing another. We’re going to act together from this point forward. We’re going to lock arms. We’re going to work through the issues that are causing difficulties for us, and we’re going to resolve them.”

Despite his determined words, however, Tillerson and Cavusoglu spent much of the news conference repeating positions both have held for months.

Cavusoglu expressed anger that a cleric Turkey suspects of being behind a 2016 coup attempt is living in Pennsylvania. Tillerson said the United States would look at any evidence Turkey presents, though in the past such evidence has been judged by courts to be insufficient for extradition.

The United States in turn is unhappy that Turkey has arrested thousands of its own citizens, as well as Americans and Turkish employees of the U.S. Embassy and consulates who U.S. officials say were just doing their jobs.

The sour state of relations has deteriorated rapidly in the past month after Turkey launched an offensive against the U.S.-backed Kurdish People’s Protection Units, or YPG, in Afrin in northern Syria. Turkey fears that the Syrian Kurdish militia will provide arms to Turkish Kurds who have been waging an armed struggle against the government. Turkish officials have portrayed the offensive — dubbed Operation Olive Branch — as a fight against terrorism and detained hundreds who oppose the campaign.

The United States and Turkey consider the Kurdish group in Turkey, known as the Kurdistan Workers’ Party, or PKK, to be a terrorist group. But its YPG allies in Syria are seen by the United States as the most effective fighters in taking on Islamic State militants.

The long-standing difference threatened to spill into the open when Erdogan warned that U.S. troops around the Syrian town of Manbij, about 90 miles east of Afrin, would feel the sting of an “Ottoman slap” if they got in the way of Turkey’s troops there.

It was unclear whether both sides walked away with the same understandings. Cavusoglu said Turkey expects U.S. troops in Manbij to withdraw east of the Euphrates River. Tillerson said U.S. forces are present to ensure that the town does not fall back into the hands of militants, but he said the specifics had to be ironed out by the working group.

He described Manbij as a starting point to be addressed as part of a final push against Islamic State stragglers. “We agreed our objectives are precisely the same,” he said, citing the destruction of Islamic State remnants and stabilizing Syria to allow the return of refugees and people uprooted within the country.

A joint statement, identical to a draft passed out by Turkish officials, seemed to have paragraphs catering to each country’s interests. It mentioned their shared goals in the promotion of democracy, the rule of law and individual freedoms throughout the world — all principles that have been strained under the state of emergency Turkey declared after the attempted coup. It also said the United States “condemns the heinous coup” attempt and expresses solidarity with Turkey’s government.

The statement followed a lengthy series of meetings between Tillerson and the Turkish leaders, followed by more meetings among aides tasked with working out the details that lasted until 2 a.m. Tillerson and Cavusoglu continued the discussion over breakfast.

With Tillerson coming to Erdogan’s home turf, the Turks appeared eager to demonstrate they were holding the upper hand. They insisted that Tillerson speak to Erdogan alone, unaccompanied by aides or an American interpreter. Instead, Cavusoglu acted as the interpreter.

State Department officials said the arrangement was not unprecedented, though secretaries of state more commonly use their own interpreters and bring aides to dicey meetings to ensure that the secretary’s words are properly translated and Americans can attest to what was said.

Just hours after the final sessions Friday, an Istanbul court sentenced three prominent journalists and three others working in media to life in prison for attempting to “overthrow the constitutional order.” They were the first journalists to be convicted over the attempted coup in 2016.

“The Turkish judicial system has made a fool of itself in the eyes of the world,” the secretary general of Reporters Without Borders, Christophe Deloire, said in a statement. The sentences against Ahmet Altan, Mehmet Altan and Nazli Ilicak “confirm that the most absolute despotism now reigns in Turkey,” Deloire said.

Tillerson’s visit came amid a rising tide of anti-Americanism in Turkey that was on full display outside the site of his breakfast with Cavusoglu. A few dozen protesters from a marginal nationalist party gathered, waving Turkish flags and chanting anti-U.S. slogans. “Murderer USA!” they chanted, comparing the United States to the outlawed PKK.

Carol Morello is the diplomatic correspondent for The Washington Post, covering the State Department. She previously wrote about demographics and the census. She has worked at The Post since 2000. Before that, she was a reporter for the Philadelphia Inquirer and USA Today.

Erin Cunningham is an Istanbul-based correspondent for The Washington Post, covering conflict and political turmoil across the Middle East. She previously was a correspondent at the paper's bureau in Cairo, and has reported on wars in Afghanistan, Gaza, Libya and Iraq.