He was responding to questions of whether mutual interests in fighting terrorism could possibly bring together Tehran and Washington -- traditional foes that have had no diplomatic relations in more than three decades.
"If we see that the United States takes action against terrorist groups in Iraq, then one can think about it," Rouhani said at a press conference marking a year since he was elected president.
Both Iranian and American leaders have separately pledged support for the government of Iraqi Prime Minister Nuri al-Maliki in fighting advancing fighters from the Islamic State of Iraq and the Levant (ISIL).
Yesterday, US President Barack Obama said Washington was considering options over Iraq short of sending troops.
Also Read
"We will not be sending US troops back into combat in Iraq, but I have asked my national security team to prepare a range of other options that could help support Iraqi security forces," he said.
The jihadists, employing brutal tactics and showing no mercy for civilians and rival rebels, have taken a swathe of mostly Sunni Arab territory in northern Iraq since launching an offensive on Monday.
Rouhani said Iran is ready to help Iraq, if asked.
"No specific request has been put forward, but we are prepared to help -- within the frameworks of international regulations -- if there is a request," he said.