Throughout 2017, President Recep Tayyip Erdogan of Turkey seemed to go out of his way to thumb his nose at onetime friends and allies.

Early this year, he described the Dutch government as “Nazi remnants,” accused German politicians of “Nazi practices” and called the entire European continent “racist, fascist and cruel.”

Relations with the United States were not much better, as both countries tightened visa requirements in a crisis ignited by Turkey’s arrest of two of its citizens who worked for the State Department in Turkey.

With just days left before the end of the year, however, Mr. Erdogan appears to have had a change of heart.