“It is our greatest duty today to correct the image of Islam in world public opinion,” Rouhani told a conference on Islamic unity in Tehran in a speech broadcast by state television.
His remarks were rare for a leader of Iran, which considers itself an authority in the Islamic world and often blames the “enemies” of the religion for problems in the Middle East.
“Did we ever think that, instead of enemies, an albeit small group from within the Islamic world using the language of Islam, would present it as the religion of killing, violence, whips, extortion and injustice?” Rouhani said.
Rouhani, a relative moderate, said Islamic principles opposed violence and the extremism of groups such as Islamic State stemmed from “narrow-mindedness and a lack of moderation”.
Rouhani criticized Muslim countries for “being silent in the face of all the killing and bloodshed” in Syria, Iraq and Yemen – conflicts in which Iran plays a role.
Iran supports the government of Syrian President Bashar Assad, has close ties with neighboring Iraq, and condemns the Islamic State group which fights both governments.
The Islamic Republic is also an ally of the Houthi movement which seized control of most of Yemen last year and has fought a military coalition led by Saudi Arabia for nine months.