Standing alongside visiting Afghan leader Ashraf Ghani, Iran's President Hassan Rouhani said the tumult hitting the region meant intelligence must be shared.
His comments came after IS, which holds swathes of Syria and Iraq, said it was responsible for a suicide bombing in Afghanistan's eastern city of Jalalabad which killed 33 people.
The attack on Saturday at a state-owned bank where government workers were drawing their salaries was the first in Afghanistan claimed by IS. More than 100 people were also wounded.
The Afghan leader has repeatedly raised the prospect of IS making inroads in his country, though the jihadist group has never formally acknowledged having a presence in Afghanistan.
Also Read
A former finance minister and World Bank technocrat, Ghani said IS presented "a serious danger and different form of terrorism".
"People die daily, we face barbarism," he said at a joint press conference, prompting Rouhani to nod in agreement.
Rouhani said: "We have agreed to cooperate further in the fight against terrorism, violence and extremism in the region, especially in border regions.
"We need intelligence sharing and, if necessary, cooperation in operations because the problems that exist are not restricted and gradually spread throughout the region, affecting everyone."
The two leaders did not specify further what they thought could be done to confront IS, which swept into Iraq from Syria last June. The group holds Mosul, Iraq's second city.
The largest such operation saw IS cleared early this month from Tikrit, a city north of Baghdad and the childhood home of executed Sunni dictator Saddam Hussein.
In Afghanistan, the Taliban have seen defections to IS in recent months, with some voicing their disaffection with their one-eyed supreme leader Mullah Omar who has not been seen in almost 14 years.
A person purporting to be an IS spokesman said in a call to AFP that the group was behind the Jalalabad bombing. An online post allegedly from IS made the same claim, but could not be verified.