BAGHDAD, Nov 17 (Reuters) - Iraqi Foreign Minister Hoshiyar Zebari and U.S. ambassador Ryan Crocker signed a long-awaited accord on Monday requiring Washington to withdraw its forces within three years.

The signing ceremony put a formal end to months of negotiations over the pact on the future of the U.S. presence, which the Iraqi government approved on Sunday. The pact must still be passed in the Iraqi parliament, but the government is confident it will achieve this by the end of the month.

"Definitely, today is an historic day for Iraqi-American relations, signing the security pact after months of difficult talks and negotiations," Zebari told reporters after exchanging signed copies with Crocker. Both men smiled and enthusiastically shook hands as officials applauded.

Apart from the troops pact, the two men signed a long-term strategic framework, which Crocker said would define relations between the countries for years in "economy, culture, science, technology, health and trade, just to name a few."

"It reminds us all that, at a time when U.S. forces will continue to withdraw from Iraq in recognition of the superlative security gains over the last few years, our relationship will develop in many other important ways."

But the main focus for Iraqis is the pact at last committing the United States to withdraw a force that now numbers about 150,000 by Dec. 31, 2011, a firm date that reflects the growing confidence of Iraq's government as violence has eased.

Iraqi leaders consider the date to be a major negotiating victory after the administration of outgoing President George W. Bush long vowed not to accept a firm timetable.

"This was a complicated and tough negotiation, and I think all Iraqis can be very proud of the substantial achievement that their negotiating team has witnessed," Crocker said.

FIRST READING

Iraqi lawmakers were due to begin a first reading of the troops accord later on Monday, the start of an approval process that should run into next week.

"The final word will be for the parliament, but the political atmosphere is positive," Zebari said.

The pact gives Iraq's government authority over the U.S. troops presence for the first time, replacing a U.N. Security Council mandate that has governed the U.S. presence since shortly after the 2003 invasion that toppled Saddam Hussein.

Under the deal, U.S. troops will leave the streets of Iraqi towns and villages by the middle of next year and leave Iraq altogether by the end of 2011. The deal also provides for Iraqi courts try U.S. soldiers for serious crimes committed while off duty, but only under very tight conditions.

The agreement's passage through parliament is likely but not assured. Followers of Shi'ite cleric Moqtada al-Sadr oppose the pact altogether, and the largest Sunni Arab bloc, the Accordance Front, says it should be put to the public in a referendum.

However, if other groups follow through on their leaders' promises to back it, the accord should pass.

The Bush administration says the accord does not need U.S. congressional approval.

Some Iraqi politicians have said it is easier to back the pact since the election of Barack Obama this month to replace Bush. Obama pledged to withdraw U.S. combat troops from Iraq by mid-2010, while his opponent John McCain opposed setting a date.

Iraq's government has become increasingly confident of its ability to maintain order as violence has declined over the past year. Last month saw the lowest death toll from violence since the invasion, according to government statistics.

Iran, which has influence among Iraqi Shi'ites, has opposed the pact. But Foreign Ministry spokesman Hassan Qashqavi did not explicitly reject the agreement on Monday, saying only that the United States must take seriously the views of Iraqi officials. (Additional reporting by Fredrik Dahl in Tehran; Editing by Dominic Evans)