The two countries "should achieve a joint plan and a practical solution, with each other's help, for uprooting terrorism in the region," Rouhani told Recep Tayyip Erdogan in a telephone call.
"A consolidation and expansion of ties between Tehran and Ankara is of paramount importance to us," he said.
Nearly a year after a US-led coalition started air strikes against the Islamic State group, Ankara has launched a two-pronged offensive against the jihadists in Syria and Kurdistan Workers' Party (PKK) militants based in northern Iraq.
The security situation has since deteriorated, with several attacks blamed on PKK fighters in Turkey, including two on the Tehran-Ankara railway, leading to a suspension of the train route.
More From This Section
Shiite Iran, an ally of President Bashar al-Assad, has urged Turkey to respect Syria's sovereignty in its bombing of IS targets.
"Any action that leads to the weakening of national governments can, in effect, encourage terrorist groups to fulfil their criminal actions," Iran's Foreign Ministry spokeswoman Marzieh Afkham said.
"Any operation against terrorism necessitates the coordination with the countries' central governments," he said.
Erdogan for his part called for more collaboration in the fight against IS.
"Daesh is part of Al-Qaeda and the continuation of the operation of this terrorist group is dangerous for the Islamic world," he said, using an Arabic acronym for IS.
"Cooperation between Iran and Turkey in fighting the terrorist groups is of huge importance.