ISTANBUL — Prime Minister Alexis Tsipras of Greece arrived in Turkey on Tuesday for a two-day visit amid signs of a growing understanding between him and President Recep Tayyip Erdogan of Turkey.

Bilateral relations between the countries remain fraught with disagreements old and new, but their leaders appear to have a pragmatic sense of each other and their political needs.

The visit follows a groundbreaking visit by Mr. Erdogan to Greece in December 2017, the first by a Turkish president in 65 years. Mr. Erdogan, who was at the time heading into an important election campaign at home, stunned his hosts by calling for a revision of the treaty that defines the border between the two countries, and by raising concerns about the Muslim Turkish minority in Greece.

The two leaders met again last July, on the sidelines of the NATO summit meeting, after Mr. Erdogan’s election to a new powerful presidency. Now it is Mr. Tsipras who faces an election, and he is expected to use the trip to burnish his own image.