Mr. Trump responded by telling Mr. Erdogan, much as he had in December, that he would be removing American troops from the area where the Turkish leader hoped to do battle with the Kurdish-led militia that has been critical American allies against the Islamic State. Turkey considers the militia a threat to its own borders and security.

Mr. Trump knows Turkey from his earlier life in real estate — he sold his brand name to the Trump Towers Istanbul in 2010 — but like presidents before him, he has struggled to devise a consistent policy toward the country.

Instead, he has focused on his personal relationship with Mr. Erdogan in conversations that people familiar with them describe as typically “fawning.” Mr. Trump usually begins by praising Mr. Erdogan, who is himself notorious for haranguing American presidents with grievances, according to those people.

“We have a great friendship as countries,” Mr. Trump said in an appearance with Mr. Erdogan that September. “I think we’re, right now, as close as we have ever been. And a lot of that has to do with the personal relationship.” The following July, he was spotted fist-bumping the Turkish leader at a NATO summit in Brussels.

That chumminess has unsettled both appointed and elected officials suspicious of Mr. Erdogan’s repressive policies, Islamist sympathies and deepening relationship with Russian President Vladimir Putin. Nearly everyone agrees, however, that simply shunning the head of a NATO-member nation at the pivot point between East and West is not practical.

The Trump-Erdogan friendship has already survived at least one major test, when relations flared over Mr. Erdogan’s continued detention of an American pastor, Andrew Brunson, who was jailed for nearly two years in a widespread crackdown after a failed coup in Turkey. When Mr. Brunson was not freed as he expected, Mr. Trump announced in a hostile tweet that he was doubling tariffs on Turkish steel and aluminum and watching the Turkish lira slide.

After Mr. Brunson was freed last October, Mr. Trump expressed public gratitude to Mr. Erdogan for “making this possible.”