Pool, Getty Images
Iranian President Mahmoud Ahmadinejad and Iraqi Prime Minister Nouri Kamal al-Maliki address media.

BAGHDAD — President Mahmoud Ahmadinejad of Iran, arriving in Baghdad to open what he declared a "new chapter" in relations between Iraq and Iran, warned President Bush on Sunday that America's problems in the Middle East would worsen as long as he continued to accuse Iran of interfering in Iraq.

The visit, the first by an Iranian leader since the brutal Iran-Iraq war of the 1980s, set off protests in Sunni Arab areas that seemed to underscore how growing Iranian influence could thwart hopes of mending the Iraqi government's sour relationship with Sunnis inside its own borders. Many of Iraq's Shiite leaders have ties to Iran.

"Today, by the grace of God, our two countries' leaders have agreed to cement their brotherly relations," Ahmadinejad said after meeting with the Iraqi president, Jalal Talabani. The Iranian leader plans to stay for two days and strike deals on energy and other investment projects.

Talabani, a Kurd, said that "economic, oil, political and security issues" are all on the table. He also reiterated previous vows by Iraqi officials to eliminate the Mujahedeen Khalq, a group of anti-Iranian guerrillas, some of whose members have taken shelter at an American-guarded compound in eastern Iraq.

Ahmadinejad later called for Iraq, Iran and Turkey to cooperate to drive Kurdish guerrillas from the Iraqi border areas they use to stage attacks into both countries. U.S. officials say the guerrillas of the Kurdistan Workers Party, who attack Turkey, a NATO ally, are terrorists. But they do not condemn a closely linked group, the Party for Free Life in Kurdistan, which carries out deadly raids into Iran.

The visit made plain the determination of Iraqi leaders to move closer to Tehran despite American accusations that Iran supports militias in Iraq. Ahmadinejad received hugs from several dignitaries who greeted him, including Vice President Adel Abdul Mahdi, a Shiite.

At a news conference, the Iraqi prime minister, Nouri Kamal al-Maliki, seemed to distance himself from American criticism of Iran. "I think that the level of trust is very high," al-Maliki said. "And I say frankly that the position Iran has taken recently was very helpful in bringing back security and stability."

A question from an Arab reporter to Ahmadinejad — about Bush administration statements that Iran provides weaponry to militias — appeared awkward for al-Maliki, who turned to Ahmadinejad as if to distance himself from the query.

"That's what he said," al-Maliki told the Iranian leader, referring to the reporter and making clear that the question did not spring from anything al-Maliki had said.

Ahmadinejad responded: "You can tell Mr. Bush that making accusations about others will increase the Americans' problems in the region. They will have to accept the facts in the area. The Iraqi people do not like the Americans."

In an appearance later with Abdul Aziz al-Hakim, leader of a powerful Shiite party, Ahmadinejad responded to a similar question by saying that the U.S. occupation had sent terrorists flocking to Iraq.

Ahmadinejad's trip almost seemed choreographed to contrast with Bush's visits, which occurred inside highly protected American compounds.

After arriving at Baghdad International Airport, Ahmadinejad rode in a motorcade — not aboard helicopters — to central Baghdad down a road once controlled by Sunni insurgents. He arrived to warm smiles from Talabani and a line of Iraqi officials at Talabani's compound, where he was under the protection of Kurdish pesh merga fighters and other Iraqi forces.

Outside Baghdad, it was clear the visit outraged many Sunni Arabs who still have raw emotions from the Iran-Iraq war and believe that al-Maliki's Shiite-dominated government functions as a proxy for Iran.

The recent move by thousands of former insurgents and other Sunnis to join American-backed militias is often ascribed solely to a revolt against Sunni jihadist militants. But many of these militiamen say they joined partly to get support from the Americans so they can prepare to resist Iranian efforts to dominate Iraq.

"I think Ahmadinejad is the most criminal and bloody person in the world," said Emad Abbas, a university student in Samarra. "This visit degrades Iraq's dignity, and it proves that Iraq is occupied twice, once by the United States and once by Iran."

In Kirkuk, where Sunnis are fighting efforts by Kurds to control the city, tribes and political parties rallied against the visit.

"How can we tolerate this?" said Salman Abdullah Al-Hamad, an Arab tribal leader in Kirkuk. "Today we live under the regime of the clerics. The Iranian revolution has been exported to Iraq."

Hundreds of Sunnis also took to the streets in Fallujah. "Ahmadinejad is the main reason why the occupiers remain in Iraq," said Muhammad Dira Farhan, 50.

"His visit is intended to reassure his followers here," he said, but he is "provoking and enraging" many Iraqis.