Updated

Secretary of State Condoleezza Rice said Thursday that the U.S. and Iraq have agreed to "time horizons" for U.S. troops to leave Iraq.

A final deal is not quite complete, but Rice and Foreign Affairs Minister Hoshyar Zebari said a withdrawal plan and accompanying strategic framework pact is close to fruition.

"We have agreed that some goals, some aspirational timetables for how that might unfold, are well worth having in such an agreement," Rice told reporters after meeting with Iraqi officials, including Prime Minister Nouri al-Maliki.

"This agreement determines the principle provisions, requirements, to regulate the temporary presence and the time horizon, the mission of the U.S. forces," Zebari said.

A draft agreement announced Wednesday would have American troops leave Iraqi cities as early as June 30. Rice flew into Baghdad on an unannounced trip on Thursday to hammer out unresolved issues.

Zebari said the pact has to go before Iraq's Executive Council for Review, but, "really, we are very, very close to closing this agreement."

Besides spelling out that U.S. troops would move out of Iraqi cities by next summer, the Iraqi government has pushed for a specific date, most likely the end of 2011, by which all U.S. forces would leave the country. In the meantime, the U.S. troops would be positioned on bases in other parts of the country to make them less visible while positioned to help Iraqi forces as needed.

U.S. officials have resisted committing firmly to a specific date for a final pullout, insisting that it would be wiser to set a target linked to the attainment of certain agreed-upon goals. These goals would reflect not only security improvements but also progress on the political and economic fronts.

On Wednesday, White House spokesman Gordon Johndroe said the calmer environment in Iraq had enabled the accord to be drafted.

"The improved security in Iraq allows us to have conversations with the Iraqis about setting goals for more American troops to come home and for the Iraqis to take the lead in more combat missions," Johndroe said. "Any dates in an agreement will be based on conditions on the ground because we do not want to lose the hard-fought gains of the surge."

On her way to Iraq, Rice too expressed optimism about progress in Iraq. However, she cautioned that a deal wasn't done.

Rice said the U.S. wants to make sure Iraqi forces are responsible for their own country's security, as has been the goal "from the beginning."

The military surge has worked and "we are making progress together in the defeat of Iraq's enemies of all stripes," she said.

The agreement "builds on the success we have had in the last year. This agreement is based on success," she added. "We're not sitting here talking about an agreement to try to get out of a bad situation."

Asked about fears expressed by neighboring countries over such a pact, Zebari said, "This (agreement) is a sovereign one, and Iran and other neighboring countries have the right to ask for clarifications. ... There are clear articles (that) say that Iraq will not be used as a launching pad for any aggressive acts against neighboring countries and we already did clarify this."

"Obviously, the American forces are here, coalition forces are here at the invitation of the Iraqi government," Rice said. "What we're trying to do is put together an agreement that protects our people, respects Iraq's sovereignty."

Iraqi and U.S. officials have been working on a Status of Forces Agreement for months and some of the negotiations appeared to be playing out in the news. Zebari acknowledged that the delay had been partly the effect of internal political factors.

Followers of anti-American Shiite cleric Muqtada al-Sadr control 30 of the 275 seats in parliament. The head of the group's political bureau on Thursday criticized Rice's visit and repeated the Sadrists' opposition to the security agreement.

"We as the Sadr movement denounce this dubious visit and such timing. We reaffirm our stance of rejecting the long-term agreement. We demand the Iraqi government, and on the highest levels, not to sign this unjust agreement and we demand the withdrawal of the government as soon as possible," said Luai Smeisem, the head of the political bureau in the Sadr movement.

The Associated Press contributed to this report.