Visiting Iraqi President Jalal Talabani has called on Iran to provide "comprehensive help" to improve his country's security situation.
Mr Ahmadinejad (left) pledged to help Iraq
Mr Talabani arrived following a two-day delay, caused by a curfew that was imposed after bomb attacks in Baghdad killed more than 200 people.
Iranian President Mahmoud Ahmadinejad told him Iran would do what it could.
The trip is part of a renewed flurry of diplomacy that sees US President George W Bush visiting Jordan this week.
Separately, United Nations Secretary General Kofi Annan has said that Iraq is close to civil war.
"I think given the developments on the ground, unless something is done drastically and urgently to arrest the deteriorating situation, we could be there. In fact we are almost there," he said.
Mr Talabani was given a red-carpet welcome by Mr Ahmadinejad at Iran's presidential palace and inspected a guard of honour.
Iranian television quoted the Iraqi president as saying: "We are in dire need of Iran's help in establishing security and stability in Iraq."
The US and UK have repeatedly accused Iran of impeding efforts to stabilise Iraq.
The trip was delayed by the Sadr City bomb attacks on Thursday
But Mr Ahmadinejad said a secure, progressive and powerful Iraq was in the interests of Iran and the whole region.
He said the situation inflicted on Iraq by its enemies pained all Iranians and Muslims.
"Any help the government and nation of Iran can give to strengthen security in Iraq will be given," he said. "We have no limitation for co-operation in any field."
Iranian officials said Iran had been trying to organise a summit including Mr Ahmadinejad, Mr Talabani and Syrian President Bashar al-Assad but that Damascus had not responded to the invitation.
The BBC's Frances Harrison in Tehran says some have suggested Iran wants to keep the US bogged down in Iraq to prevent it attacking Iran in the future over its nuclear programme.
But she says it seems Iran is increasingly concerned about the uncontrollable level of violence in Iraq.
Mr Ahmadinejad has previously said Iran is willing to help but only if the US changes its approach and abandons what it calls its "bullying" of Iran.
Mr Talabani is also meeting Iran's Supreme Leader Ayatollah Ali Khamenei during his visit, which is being keenly watched in the West.
Increased contact with Iran and Syria is one of the options being considered by the US Iraq Study Group, which is in its final stages of deliberation on recommending what new policies Washington could adopt on Iraq.
There have been suggestions the US administration is looking for a new approach following heavy mid-term election losses.
Mr Bush is to meet Iraqi Prime Minister Nouri Maliki in Jordan this week while Vice-President Dick Cheney has just been in Saudi Arabia.
Last week's multiple car bomb attacks in Baghdad's Sadr City - in which 250 people were also wounded - were the deadliest in Iraq since the US-led invasion of 2003.
Last week, the United Nations said violent deaths among civilians hit a record high in October, with more than 3,700 people losing their lives - the majority in sectarian attacks.