Iranian Foreign Minister Mohammad Javad Zarif, who arrived in the Iraqi capital earlier in the day, thanked Baghdad for having "refused the unjust and illegal sanctions imposed on the Iranian people", in reference to the US sanctions.
Rouhani, a relative moderate, used the start of his three-day trip to criticize the United States, which has sought to isolate Iran.
"Iran-Iraq relations are not comparable with (Iraq´s relations) with an aggressor country like America", Rouhani said.
Iraq, which receives financial and military support from Washington, has attempted to balance its relations with the United States and Iran, which carries significant influence with members of Iraq's Shi'ite population.
"We want to be united countries, not against others, but attracting others to our unity", Rouhani said.
He will visit a Shia shrine in the Iraqi capital and then meet President Barham Salih and Prime Minister Abdel Abdul Mehdi, as well as visit other politicians and Shia leaders.
Iraq was given limited waivers to continue buying electricity and natural gas from Iran, with Washington calling on Baghdad to partner with USA companies to become energy independent.
The deals, among them a plan to build a railway linking the neighbors, emerged soon after the start of Rouhani's visit, meant to underline that Tehran still plays a dominant role in Iraq despite US efforts to isolate the Islamic Republic.
McIlroy making a move at PGA Palmer event
One is a Srixon 4-iron, which he hammered from 224 yards over the corner of the lake to 18 feet on the par-5 sixth for eagle. A bogey on the par-four eighth stained his scorecard and put him one stroke behind Fitzpatrick in solo second place.
Jaguar that attacked selfie-taking woman won't be put down
Gilleland later revealed that the woman was taken to a nearby hospital and following treatment, returned to the zoo to apologize. Several people rushed over to help but it was a mother and son - Michele Flores and Adam Wilkerson - who pulled her to safety.
French football star Zinedine Zidane reappointed as Real Madrid's head coach
We have enormous respect for the position and we always support the Real Madrid coach. "We the players are primarily responsible and I, as captain, more than anyone".
"Iraq is another channel for Iran to bypass America's unjust sanctions imposed on Iran".
Iran also sees Iraq as a possible route to bypass US sanctions that Trump re-imposed previous year after pulling the USA out of the 2015 nuclear deal.
The two countries fought a bloody war from 1980 to 1988 and Tehran's influence in Baghdad grew after the 2003 US-led invasion of Iraq toppled the government of Saddam Hussein.
Rouhani, who had visited Iraq privately before becoming president, had planned an official visit in 2016 but it was canceled over unspecified "executive" problems.
Last year, Iran's exports to Iraq amounted to almost $9 billion US.
He pointed out that Iran had stood by Iraq in "difficult" times - a reference to its training and arming of thousands of Iraqi Shia paramilitary fighters who have helped drive Islamic State (IS) militants out of the large parts of Iraq they seized in 2014.
Last year, Iran's exports to Iraq amounted to almost $9 billion.
The premier expressed his heartfelt condolences on the recent terrorist attack in Iran in which 27 Revolutionary Guards were killed, the PM Office statement said. Tehran hopes to increase the roughly $13 billion volume in trade between the two neighbouring countries to $20 billion.