Expectations of progress remain low, however, with tough issues at stake and mutual suspicions running high. Even as it announced the talks Sunday, Iran lashed out at Vice President Dick Cheney's weekend warnings about its nuclear program, saying it would retaliate if the U.S. attacked it.
Yet the two sides said they were setting aside such differences to focus on a narrow issue — Iraq's continued violence and sharp political deterioration.
"The purpose is to try to make sure that the Iranians play a productive role in Iraq," said Gordon Johndroe, the White House's National Security Council spokesman.
Cheney's spokeswoman, Lea Anne McBride, also confirmed the upcoming talks, saying the vice president supports the move as long as they focus solely on Iraq.
Despite the agreement to meet in Iraq, Iran's hard-line president kept up his anti-American rhetoric, leading a raucous rally in Dubai — a tightly controlled U.S. ally in the Persian Gulf.
President Mahmoud Ahmadinejad's speech at the rally came a day after a low-key visit by Vice President Dick Cheney, which was aimed at countering Tehran's influence in the region.
Ahmadinejad told a cheering crowd Sunday that America was to blame for creating instability and robbing the region of its wealth.
"We are telling you to leave the region. This is for your benefit and the benefit of your nation," Ahmadinejad shouted to the crowd of thousands at a soccer stadium. "The nations of the region can no longer take you forcing yourself on them. The nations of the region know better how to create peace and security."
Iran agreed to the direct talks with the U.S. "after consultation with Iraqi officials, in order to lessen the pain of the Iraqi people, support the Iraqi government and establish security and peace in Iraq," the state-run news agency, IRNA, quoted Foreign Ministry spokesman Mohammad Ali Hosseini as saying.
Iraqi leaders have leaned on the Bush administration to try to cooperate with Iran in the interest of stabilizing their country. Likewise, some Mideast Arab allies of the U.S. — increasingly distrustful of Iraq's Shiite-led government — have pushed for talks with Iran as a way to reduce sectarian tensions in the country and stop attacks against Sunnis.
The decision to talk comes at a critical time of plunging U.S. support for the war and growing pressure from Congress for Iraq's government to make some political progress, or lose U.S. backing. Many critics say the U.S.- and Iraqi-led security push and troop buildup is also struggling.
In March, lower-level U.S. and Iranian diplomats did hold rare, brief talks on the sidelines of a Baghdad gathering. At a follow-up conference a week ago in Egypt, there was a casual chat between the U.S. ambassador to Iraq, Ryan Crocker, and Iran's deputy foreign minister, Abbas Araghchi.
There had been speculation of a Cabinet-level meeting at that Egypt conference, but neither Secretary of State Condoleezza Rice nor Iran's foreign minister wanted to make the initial move, passing up what would have been the first high-level, face-to-face talks since the U.S. broke off relations with Tehran after the 1979 hostage crisis.
Until this spring, the Bush administration had dismissed calls for both outreach to Iran and Syria. At the Egyptian conference, Rice did sit down for a talk with Syria's top diplomat.
The timing of the upcoming talks in Baghdad was unclear, but Johndroe and Iraq's foreign minister, Hoshyar Zebari, both said they expected them to occur sometime in the next few weeks. The talks could be between Crocker and the Iranians, Johndroe said.
The Baghdad setting will allow for "serious, quiet and focused discussions on the responsibilities and the obligations of all to help stabilize the situation in Iraq," Zebari said.
Despite the planned talks, mutual suspicion and tension between the two countries runs high.
During a visit to the United Arab Emirates, hard-line Iranian President Mahmoud Ahmadinejad demanded Sunday that the U.S. leave the Middle East — two days after Cheney warned Tehran that Washington will not allow it to develop nuclear weapons or dominate the region.
"We are telling you to leave the region. This is for your benefit and the benefit of your nation," Ahmadinejad told the crowd at a soccer stadium in Dubai.
Iran has stressed that it sees the U.S. military presence in Iraq as a serious threat to its security. More than 140,000 U.S. troops are in Iraq — with more expected this month as part of a stepped-up Baghdad security operation.
The U.S. sees Iran as the biggest threat to Iraq's stability, accusing Tehran of supplying Shiite militias with deadly roadside bombs that kill American troops. Iran denies the accusations.