ANKARA, Turkey — Turkey and Iran, on opposing sides of the civil war in Syria, signaled a thaw in relations on Friday, asserting that they shared concerns about the rise in sectarianism there and could collaborate to bring peace to their neighbor.

The softening, reflected in the Iran foreign minister’s visit to Turkey, came as the international community was working toward talks to end the Syrian conflict. Turkish officials appeared to be trying to position themselves as a bridge between the West and Iran on Syria, as Turkey has done on the Iranian nuclear issue.

In an afternoon meeting here between Mohammad Javad Zarif, the Iranian foreign minister, and Recep Tayyip Erdogan, Turkey’s prime minister, Mr. Erdogan made clear that he still believes that President Bashar al-Assad of Syria must go. A senior Turkish official who spoke on the condition of anonymity said that Turkey was willing to support a plan in which some institutions of the Syrian state remained intact, and that Turkey was pressuring Iran to abandon Mr. Assad.

Privately, Turkish officials say that despite the diplomatic push, Turkey will continue to support rebel fighters in Syria even as peace talks appear to be looming. Turkish officials say that in their meetings with Western officials they argue that the rebels need to fight on so they are not negotiating with Mr. Assad from a position of weakness.