Iranian President Mahmoud Ahmadinejad, on an unprecedented visit to Iraq, was aiming to build ties with officials from a once-hated neighbor and to accuse the United States of spreading terrorism. The two-day visit was thick with symbolism as both the US and Iran seek to influence Iraq's future. Ahmadinejad said talks Sunday with Iraqi President Jalal Talabani, a Sunni Kurd who told the Iranian leader to call him "Uncle Jalal," were "brotherly." Then Ahmadinejad cut through the US-controlled Green Zone to visit Prime Minister Nouri al-Maliki, a fellow Shi'ite, at his Cabinet offices. The sprawling Green Zone contains the core of the US diplomatic mission to Iraq - including a massive new embassy - and is heavily protected against occasional rocket attacks, which American officials have blamed on Iranian-backed Shi'ite extremists. Ahmadinejad denied the charges at least twice during news conferences throughout Sunday. "Six years ago, there were no terrorists in our region. As soon as the others landed in this country and the region, we witnessed their arrival and presence," he said Sunday night after meeting Abdul-Aziz al-Hakim, the leader of Iraq's largest Shi'ite political bloc. Earlier, Ahmadinejad said that "such accusations increase the problems of the Americans in the region. The Iraqi people do not like the Americans." The Iranian delegation seemed to enjoy the contrast between Ahmadinejad's visit and trips to Iraq by US President George W. Bush. Ahmadinejad announced the dates of his visit in advance, landed at Baghdad International Airport in daylight and drove through the capital, albeit in a heavily guarded convoy, on a relatively quiet day. Iraqi forces provided security. The Iranian leader also visited the holy Shi'ite shrine of Imam Mousa al-Kadim around midnight. He traveled in a motorcade under tight security through Baghdad's streets to the shrine in the northern Kazimiyah district, about 12 kilometers from al-Hakim's headquarters where he departed. In contrast, Bush's visits are typically a surprise and involve trips mostly to US military bases, like his journey to an air base in Anbar province last September. The day before the Iranian president arrived, the chairman of the US Joint Chiefs of Staff, Adm. Mike Mullen, came to Baghdad unannounced to visit with commanders and Iraqi officials. On Saturday, Bush advised al-Maliki to tell the Iranian leader to "quit sending in sophisticated equipment that's killing our citizens." Rear Adm. Gregory Smith, a military spokesman, reiterated Sunday that the US hopes the Iranian-Iraqi meetings produce "real and tangible results," which in the American view would include Iran ending its alleged training and funding of extremists. The tone among Ahmadinejad and his Iraqi hosts, meanwhile, was more than cordial. "We had very good talks that were friendly and brotherly," Ahmadinejad said after meeting with Talabani, who greeted him with an honor guard and a band that played both countries' national anthems. "We have mutual understandings and views in all fields, and both sides plan to improve relations as much as possible." After a meeting involving Ahmadinejad, al-Maliki and their advisers, the Iraqi prime minister said the visit was "an expression of the strong desire of enhancing relations and developing mutual interests after the past tension during the dictatorship era." Ahmadinejad was set to meet with Talabani again Monday before returning to Teheran. While both countries have a Shi'ite majority, their relationship has been checkered. They were hostile to each other throughout the long reign of Saddam Hussein, a member of Iraq's Sunni minority, and fought a catastrophic eight-year war after Saddam invaded Iran in 1980. About 1 million people died in the conflict. But when Saddam's Sunni-dominated regime fell to the US-led invasion and Iraq's Shi'ite majority took power, long-standing ties between the Shi'ites of both countries flourished. Ahmadinejad said he was "very pleased with his visit to an Iraq not ruled by a dictator." Still, the Iraqis are precariously balanced between US and Iran, with government officials saying in recent weeks that they don't want the country torn apart in a power struggle between the two sides. Hundreds of protesters gathered Sunday in Fallujah, the scene of two battles between US troops and Sunni insurgents, and demonstrated for an hour against Ahmadinejad's visit. "The chieftains of Fallujah condemn the visit of Ahmadinejad to Baghdad," one of their banners read. Another 50 people demonstrated against the visit in northern Kirkuk, and tribal chieftains in the country's Shi'ite-dominated southern region signed a petition against the visit. Adnan al-Dulaimi, one of Iraq's most influential Sunni politicians, called for restraint. He said the visit indicated the strong Iranian influence in Iraq but said he hoped it would decrease tension between the two countries. "We call upon the United States and Iran not to make Iraq a field for their struggle," he said.