The action was accordingly taken and nine out of 12 abducted Iranian personnel were rescued by the Pakistani forces, he said, and added that Prime Minister Imran Khan is scheduled to visit Iran on Sunday during which security issues will be discussed in detail.
The announcement came during a two-day visit to Iran by Pakistani Prime Minister Imran Khan, the first of his tenure.
He said that "the four decades of war in Afghanistan has affected Pakistan and Iran and added that Pakistan hosted at one point four million refugees and today it hots 2.7 million Afghan refugees".
The Pakistani delegation headed by Imran Khan visited the holy shrine of the 8th Imam of Shias on Sunday afternoon, followed by a meeting with Hojjatolesm Marvi as the new custodian of Imam Reza holy shrine.
"We agreed to create a joint rapid reaction force at the borders for combating terrorism", Rouhani said, following months of increased tensions over attacks on both sides of the two countries' frontier.
The Islamic Republic has previously put forward similar demands, calling on Pakistan to act against terrorists following a February attack that killed 27 members of the Revolutionary Guards in Iran's Sistan-Baluchistan. Pakistan lodged a strong protest with Iran over the country's "inaction" against the group behind the attack, according to The Express Tribune.
Pakistani Foreign Minister Shah Mahmood Qureshi said on Saturday the training and logistical camps of the new alliance that carried out the attack were based inside Iran and called on Iran to take action against the insurgents.
Like this story? Share it with a friend!
Iran's Shi'ite Muslim authorities say militant groups operate from safe havens in Pakistan and have repeatedly called on the neighbouring country to crack down on them.
"The most important reason why I'm here, Mr. President, is because I felt that the issue of terrorism was going to ... increase differences between our countries", Khan said during the joint news conference.
Analysts say Pakistani leaders would have worked hard during the two-day visit to establish cooperate with their Iranian counterparts on the issue.
Balochistan, which borders Afghanistan and Iran, is Pakistan's largest and poorest province, rife with ethnic, sectarian and separatist insurgencies.
"It is a vast area and the control over the area is hard, it makes it easy for groups to be active on both sides", he said.
Stressing that "no third country" could harm bilateral ties, an apparent reference to the United States and its policy of isolating Iran, Rouhani said Tehran was ready to boost trade and business ties with Islamabad.
Iran has accused regional rival Saudi Arabia of funding armed rebels. He said despite worsening human rights situation in the Indian-held Kashmir, Pakistan intends to normalise its relations with India.
Asad Hashim is Al Jazeera's digital correspondent in Pakistan.