The Iranian leader went from Baghdad's airport to a meeting with Iraqi President Jalal Talabani, who gave him a red-carpet welcome. The two kissed four times on the cheek in the traditional fashion and a band played the two countries' national anthems.
"We had very good talks that were friendly and brotherly. ... We have mutual understandings and views in all fields, and both sides plan to improve relations as much as possible," Ahmadinejad said in a news conference with Talabani at the Iraqi president's residence, located across the Tigris River from the new U.S. Embassy in the fortified Green Zone.
Talabani said the two discussed economic, political, security and oil issues and planned to sign several agreements later. But he said the issue of borders, including the disputed Shatt al-Arab waterway between the two countries, was not discussed.
Iran has denied U.S. charges that it aids militants, and Ahmadinejad stressed that his country wanted a stable Iraq that would benefit the region.
"A united Iraq, a sovereign Iraq and an advanced Iraq is to the benefit of all regional nations and the people of Iran," he said.
The news conference appeared to end abruptly after a reporter asked Ahmadinejad about the People's Mujahedeen Organization of Iran, which was allied with Saddam during the bitter 1980s war between the two countries. The group has opposed Iran's Islamic republic and has operated out of Iraq. The U.S. and European Union list it as a terrorist organization.
Talabani interjected, saying: "This issue has been discussed earlier and the presence of those as a terrorist organization is constitutionally not allowed. We will endeavor to get rid of them out of the Iraqi territory soon."
After discussions with Talabani, Ahmadinejad went to meet Iraqi Prime Minister Nouri al-Maliki. Both of the Iraqi leaders have made official visits to Iran since taking office.
The U.S. has said it will have no involvement in Ahmadinejad's visit. Ahmadinejad arrived in Iraq a day after Adm. Mike Mullen, chairman of the Joint Chiefs of Staff, came to Baghdad on an unannounced visit with commanders and Iraqi officials.
Iraqi Foreign Minister Hoshyar Zebari told The Associated Press that Ahmadinejad plans to leave Monday morning.
Though both are Shiite-majority countries, Iran and Iraq were hostile to each other throughout Saddam's regime. Their eight-year war after Saddam invaded Iran in 1980 cost about 1 million lives.
But when Saddam's Sunni-dominated regime fell and Iraq's Shiite majority took power after the 2003 U.S.-led invasion, long-standing ties between the Shiites of both countries flourished again, though the two neighbors have yet to sign a peace treaty.
Many of Iraq's Shiite leaders lived in exile in Iran during Saddam's rule, and Talabani, a Sunni Kurd, speaks fluent Farsi.
With the trip, Ahmadinejad also may be trying to bolster his support back home ahead of parliamentary elections later this month. They are seen as referendum on the Iranian president, who has come under criticism in his country for spending too much time on anti-Western rhetoric and not enough on Iran's economic problems.
The U.S. has tried to downplay Ahmadinejad's visit. It has said it welcomed Iran's stated policy of promoting stability but that its actions have done just the opposite.
President Bush denied that Ahmadinejad's visit undermined U.S. efforts to isolate Tehran, but had some advice for what al-Maliki should say to the Iranian leader.
"He's a neighbor. And the message needs to be, quit sending in sophisticated equipment that's killing our citizens," Bush said.
In Tehran, Iran Foreign Ministry spokesman Mohammad Ali Hosseini criticized Bush.
"His remarks are an intervention in the friendly, brotherly and sincere relations between Iran and Iraq," Hosseini told reporters Sunday after Ahmadinejad left Iran. "Americans do not want the relations to grow."