ISTANBUL — In their recent encounter at the NATO summit meeting, President Recep Tayyip Erdogan of Turkey and President Trump gave each other a fist-bump, as Mr. Trump declared, “I like him, I like him.”

The love fest was short-lived. Days later, the Trump administration imposed financial sanctions against two ministers of Mr. Erdogan’s cabinet, sending the Turkish lira plummeting and a stream of nationalist invective pouring forth from the Turkish media. Mr. Erdogan retaliated last weekend with sanctions of his own against his ministers’ American counterparts.

The tit-for-tat exchange has led many to fear that the longtime allies were headed toward an irreparable rift, driven by two leaders who each pride themselves on driving a hard bargain, in this case over Turkey’s detention of an American pastor, Andrew Brunson, who was swept up in Mr. Erdogan’s sweeping crackdown after a failed coup in 2016 and accused of espionage.

Combative politics is written in Mr. Erdogan’s DNA, one Turkish columnist explained, and for that matter, it seems, in Mr. Trump’s. Indeed, according to diplomats, the several phone calls that have taken place between the two men this year have been stormy.