Baghdad was given limited waivers to continue buying electricity and natural gas from Iran
Iran's President Hassan Rouhani hit back Monday against pressure from the "aggressor" United States on Iraq to limit ties with its neighbour, during his first official visit to Baghdad.
Shia majority Iraq is walking a fine line to maintain good relations with its key partners Iran and the United States which themselves are arch-foes.
It has been under pressure from Washington not to get too close to the Islamic republic next door, particularly after the United States last year withdrew from the 2015 nuclear deal with Iran and hit Tehran with sanctions.
Baghdad was given limited waivers to continue buying electricity and natural gas from Iran, but Washington has urged Iraq to partner with US companies to become energy independent.
Rouhani, who is on his first trip to Iraq since becoming president in 2013, hailed his country's "special" ties with its neighbour.
These relations could not be compared to Iraq's ties "with an aggressor country like America", he said before flying Monday to Baghdad for the three-day visit.
"America is despised in the region. The bombs that the Americans dropped on Iraqis, Syrian people and other countries cannot be forgotten," he added.
Iran is always ready to help its neighbours, he said, in a nod to the role Tehran played to help Iraq battle the Islamic State group.
Iraq's President Barham Saleh, at a joint news conference with Rouhani in Baghdad, thanked Iran for its "support" and said he was "lucky" to have it as a neighbour, without making any reference to the US.
Rouhani, who is heading a large political and economic delegation, said relations between the two countries should be further "reinforced and developed."
The Iranian president later had a meeting with Prime Minister Adel Abdel Mahdi, during which he highlighted the political, trade and energy links between the two neighbours.
After Turkey, Iran is the top supplier of imported goods to Iraq, including cars, gas, home appliances and vegetables.
Iran was the first country to respond to Iraqi calls for help after IS jihadists in June 2014 captured the main northern city of Mosul as they threatened to overrun the capital Baghdad and the oil-rich region of Kirkuk.
It dispatched "military advisors" and equipment along with the famous Revolutionary Guards elite Quds Force commander General Qassem Soleimani.
Rouhani on Monday said Iran has supported the Iraqi people "during difficult times" and would continue to back them "through times of peace and security."
Relations between the two countries were not always close - they fought a bloody war from 1980 to 1988.
Tehran's influence in Baghdad grew after the 2003 US-led invasion of Iraq toppled the government of Saddam Hussein.
Iran now has significant leverage over Iraq's Shia political groups.
Rouhani is also set to meet Iraq's chief Shiite cleric Grand Ayatollah Ali Sistani, who is revered by many Iranians.
The meeting in the Shiite shrine city of Najaf will be the first between the top cleric and an Iranian president. In 2013 the grand ayatollah refused to receive Rouhani's controversial predecessor Mahmoud Ahmadinejad.
Warming Saudi ties
Analysts say talks between Sistani and Rouhani are aimed at bolstering the ranks of Shiite Muslims in the face of Iraq's warming ties with Iran's Sunni-ruled rival Saudi Arabia.
The meeting could "prevent Saudi Arabia and its allies from sowing discord" between Iran and Iraq, a Shiite cleric from the Iranian holy city of Qom was recently quoted as saying in Iran's Ebtekar newspaper.
Saudi Arabia is keen to develop relations with Baghdad to counter the influence of Iran in Iraq, which is seeking economic benefits to rebuild after the defeat of IS.
Iraqi political analyst Hisham al-Hashemi said Rouhani is seeking to bolster trade with Baghdad and discuss ways "to circumvent US sanctions."
"In addition, there are electricity, water and other files," he said.
Trade between Iran and Iraq now stands at around $12 billion a year - tilted toward Iran with gas and energy exports - and Rouhani has said he would like to see it rise to $20 billion.