"We must remove Islam's negative image from today's cyber and real space," he said in Tehran at an international conference on "The Islamic World's Current Crisis".
Most "violence, terror and massacres, unfortunately, take place in the Islamic world," he said.
"I invite all Islamic countries in this region and beyond -- even those who until today have bombed and launched missiles on their neighbours -- for all of us to stop this and choose the right path," he said.
He did not give any country names.
Shiite Iran supports Yemen's Huthi rebels, while its Sunni-ruled regional rival Saudi Arabia leads a military coalition that has been bombing them in support of the loyalists since March.
"How many bombs and missiles have you purchased from America this year?" he asked.
Signup to our newsletter and follow us on Facebook and Twitter!
"If you had distributed the money for those bombs and missiles among poor Muslims, nobody would be going to bed hungry."
Tehran also backs the Syrian regime, whose army is fighting rebels and jihadists, including the Islamic State group that has taken over large swathes of the country and neighbouring Iraq.
"If some groups like Daesh can recruit soldiers, the reason is financial and cultural poverty," Rouhani said, using an Arabic acronym for IS.
Both types of poverty should be eliminated from "Islamic society", he said. "Terrorism will not be destroyed by bombs."
"For years and years, we have talked of unity. Is unity possible without economic connections within the Islamic world," he asked.
The Syria and Iraq conflicts only benefit Israel and "those who are against Muslims", he said.