Turkey's President Recep Tayyip Erdogan, makes a statement prior to his trip to China, followed by a trip to Washington, in Ankara, Turkey, Friday, May 12, 2017. (AP/AP)

Barely two months ago, Turkish President Recep Tayyip Erdogan was one of President Trump’s biggest fans. Fed up with what he saw as the Obama administration’s wishy-washy Syria policy, its unwise alliance with Kurdish “terrorists” and its failure to understand the need for some of his authoritarian policies, Erdogan envisioned a new dawn in U.S.-Turkish relations.

But as he prepares to meet with Trump on Tuesday in Washington, Erdogan has been less than pleased.

Last week, his top military and intelligence officials traveled here for a final effort to stop the administration from arming Syrian Kurdish fighters for an upcoming offensive in Raqqa against the Islamic State, only to be told by their U.S. counterparts that a decision to do so had already been made.

At the same time, his justice minister brought new evidence to support Turkey’s long-standing extradition request for Fethullah Gulen, the Pennsylvania-based Turkish cleric Erdogan holds responsible for a failed coup attempt last July. The U.S. Justice Department thanked him and sent him away with no news of progress.

The purpose of those visits was “to pave the ground for fruitful discussions between the two presidents. We were hopeful,” a senior Turkish official said afterward. “Now, we are in a crisis period.”

In remarks to reporters Friday, Erdogan appeared simultaneously to hold out hope that he could persuade Trump to change his mind — and to prepare for failure.

“We have sent a delegation ahead to the U.S., and they have held meetings with officials,” Erdogan said before he headed to China en route to Washington. “However, the highest level of discussions will be held between President Trump and me.” Their first face-to-face meeting, he said, would be a “milestone” in U.S.-Turkish relations.

Turkey’s pro-government Daily Sabah suggested that Obama administration holdovers had somehow snookered Trump officials, ramming through the decision on arming the Kurds before Erdogan arrives here.

“America is going through a transitional period currently,” Erdogan said, and Turkey “must be more careful and sensitive.”

But Defense Secretary Jim Mattis, who met with Turkish Prime Minister Binali Yildirim last week in London, after the arming decision had been announced, described it as final. “I have no doubt,” Mattis said, “that Turkey and the United States will work this out with due consideration, significant attention paid to Turkey’s security.” The important thing, he said, is that they present a “united front” against terrorism.

“Oftentimes, it can be untidy,” Mattis said of keeping allies focused on that goal.

Beyond the crisis, both Turkey and the United States will look for elements of a “positive agenda,” said the senior Turkish official, who spoke on the condition of anonymity because of the sensitivities of the upcoming visit. Trade between the two countries is small, at only $17 billion a year — although the United States sells about twice as much to Turkey as vice versa — and both sides would like to expand it.

Trump, who has said that he will be “respectful” of the domestic decisions made by other governments, is unlikely to dwell on the mass arrests and restrictions on free expression since the coup attempt, about which even his own State Department has expressed concerns. Last month, he called to congratulate Erdogan on winning a referendum, widely criticized by other U.S. allies, that vastly increased presidential power in Turkey.

On the Gulen matter, Erdogan is expected to discuss some interim steps that his government has already asked for, such as Justice Department questioning of the cleric and restrictions on his U.S. movements while the extradition request is pending, or at least an effort to curtail the weekly video messages he sends to his followers in Turkey.

But the main subject on Turkey’s mind is the People’s Protection Units, the military arm of the Kurdish Democratic Union Party, which is the primary U.S. proxy in the fight against the Islamic State in Syria. Turkey considers the force, known as the YPG, to be a terrorist ally of the Kurdistan Workers’ Party, or PKK, a separatist Turkish organization that both Ankara and Washington have labeled terrorist.

Erdogan believes that the U.S. government — first Obama and now, apparently, Trump — are naive about the YPG and its territorial ambitions, and that support for the group is both setting up an ethnic conflict in Syria and aiding PKK terrorism in Turkey itself.

A decision to directly arm the YPG was made by President ­Barack Obama before he left office, according to Colin Kahl, a former top national security aide to Vice President Joe Biden. But during the transition, Kahl wrote in an article last week in Foreign Policy, Michael Flynn, Trump’s then-incoming national security adviser, “asked the administration to hold off” so Trump could review the situation. Flynn, Kahl noted, was later found to be a paid consultant to pro-government Turkish interests.

At the end of the day, Kahl said, Trump came to the same conclusion as Obama, but only after Erdogan had won his referendum without the annoyance of an open breach with Washington.

Turkey has long insisted that U.S. arms were already going directly to the Syrian Kurdish group. As evidence, it points to U.S. weapons seized from the PKK — saying they were funneled from the YPG — and the fact that the United States has been unable to dislodge Kurdish fighters from controlling Arab parts of northern Syria that they have seized, with U.S. assistance under Obama, along the Turkish border.

As they prepare for the offensive in Raqqa, the Islamic State’s de facto Syrian capital, the Americans have told Turkey that the YPG will not be permitted to stay in the city but will turn over control to Arab elements that are part of the combined, U.S.-backed Syrian Democratic Forces. The Turks say they have heard that story before, in liberated northern towns such as Manbij, which remain under YPG control.

“They say it’s a very difficult decision . . . they don’t have any other alternatives, so on and so forth,” the senior Turkish official said. “It’s the same story. We are in a vicious circle. We keep on explaining that it’s not the only alternative, and they keep saying it’s the only alternative.”

“Put yourself in the shoes of the Turkish president,” the official said. “Could you accept that kind of decision? Here is an ally, for 60 years now — even before NATO. We fought side by side in Korea. We have fought in Somalia, in Kosovo, in Macedonia, in Bosnia-Herzegovina. Side by side. Now, instead of siding with your ally — which has 800,000 soldiers — you are opting to side with a terrorist organization.”

Turkey has offered its own troops, and separate Syrian Arab forces under its wing, for the Raqqa offensive, but the Americans maintain that the Kurds have proved their mettle and are ready to move. Although, in deference to Turkey, U.S. commanders have refrained until now from directly arming the YPG, they say the urgency and magnitude of the Raqqa offensive gives them no choice.

The YPG-dominated Syrian Democratic Forces, a Pentagon statement announcing the decision said, is “the only force on the ground that can successfully seize Raqqa in the near future.”

“They keep saying that time is of the essence for the liberation of Raqqa, that all of the planning is done,” the Turkish official said. “They’ve been saying that for a year now.”

U.S. officials have said they are confident they can keep the YPG from taking over Raqqa, but Turkey is doubtful. “If they say no, how are you going to force them out?” the Turkish official said. “The United States is trying to substitute a threat, which is against the West’s interests, with a threat against Turkey.”

The official said Turkey would leave open its options to attack the YPG itself — as it did when Turkish warplanes last month struck YPG and PKK positions on the border, killing 20 YPG fighters only miles from U.S. Special Operations forces and nearly causing an open breach with the Pentagon.

Turkey also retains the option of canceling an agreement that allows U.S. and anti-Islamic State coalition warplanes to fly out of its air base at Incirlik.

Karim Faheem in Istanbul contributed to this report.