PM Modi reiterated India's commitment to help Afghanistan become "a peaceful, secure, permanent, prosperous and pluralistic country" after holding talks with Mr Rouhani in New Delhi on the last day of his three-day visit.
"Looking at our common interests, we are committed to stopping the expansion of such forces that promote international organised crime in terrorism, extremism, illegal drug trafficking, cyber-crime and various forms," PM Modi said.
"We want to see our region and the world free from terrorism."
There was no mention of financial assistance or providing weapons to help Afghanistan fight militants by either leader.
India has been a key supporter of Kabul's government and has poured more than $2 billion into the country since the Taliban were toppled in 2001.
In 2016, India offered $1 billion in economic aid to strengthen various sectors in the war-torn nation including education, health and agriculture.
India has been a key purchaser of Iranian oil and gas, and maintained trade ties even as international sanctions were imposed on Tehran over its nuclear programme between 2012 and 2016.
India's foreign ministry said Saturday that "discussions continue" for awarding a contract on Farzad B, a major gas field in the Gulf.
The two leaders also signed agreements for avoidance of double taxation and the implementation of an extradition treaty from 2008.
As part of a lease contract, India will help Iran run a multi-purpose container terminal at Chabahar for 18 months.
India, Iran and Afghanistan signed a three-way transit agreement in 2016 to develop Chabahar port aiming to boost economic growth in the region.
Get Breaking news, live coverage, and Latest News from India and around the world on NDTV.com. Catch all the Live TV action on NDTV 24x7 and NDTV India. Like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.