In trading accusations, each decries the other’s refusal to acknowledge its view of reality, while ignoring the fact that each has acted in ways for which it faults the other — including deploying military forces to wars beyond their borders and supporting militias, both aimed at controlling whatever emerges from the debris of today’s turmoil in Syria and Iraq.

Both countries have attempted to build on shared interests — defeating or at least marginalizing the Islamic State and curbing the rise of Syrian Kurds seeking autonomy — but deep suspicions about the other’s ambitions to benefit from the chaos have stopped them from reaching an arrangement that could reduce tensions.

To reverse course and avoid worse, Turkey and Iran need to overcome mistrust and go beyond merely managing differences — with the risks of accidents, miscalculations and miscommunications this entails — and, for once, frankly acknowledge each other’s core interests and security concerns.

To this end, they need to establish a channel for continuous high-level negotiations over Iraq and Syria. The pace of such meetings to date has been problematic: periodic senior-level encounters lasting one or two days, followed by relatively long periods of diplomatic vacuum often filled with the escalation of proxy wars and one-upmanship. Mr. Erdogan and Supreme Leader Ali Khamenei of Iran should designate personal representatives with the authority to manage the diplomatic channel.

Beyond this, the governments should also find ways to increase cooperation and trust, like sharing intelligence to better fight common foes and avoid accidental clashes, and coordinating steps that could defuse tensions where their spheres of influence collide. As a first step, in northern Iraq, Iran might offer to rein in Shiite militias deployed in Nineveh Province in return for Turkey’s agreeing to withdraw its tanks and other heavy weapons from the area. The United States and Russia, which have strong military ties with Turkey and Iran respectively, should support such steps, despite their differences.

Among the countries involved in the ever-worsening proxy wars in Iraq and Syria, no two are more suited to seeking mutual accommodation than Turkey and Iran. As mature states with a long history of peaceful relations, they should not allow themselves to be sucked further into an uncertain future. Only by finding common ground can they contribute to a more stable and secure region. The alternative is even greater disorder and suffering.