The US Senate has voted to approve a bill which requires US troops to start withdrawing from Iraq by October.
President Bush says the bill will undermine US forces in Iraq
President George Bush has said he will veto the Democrat-sponsored bill, which was also passed by the House of Representatives on Wednesday.
Mr Bush says he is committed to his "surge" strategy, under which more US troops are being poured into Baghdad.
Earlier the top US general in Iraq, David Petraeus, said reducing forces could lead to increased violence.
The Senate voted 51 to 46 in favour of the bill, which makes $100bn (£50bn) in further funding for the war conditional on a timetable for withdrawal.
It says the pull-out must start by 1 October this year, and sets a target of completion by 31 March 2008.
"It sets us on a new course, away from a civil war with no end in sight toward a responsible phased redeployment that holds Iraqis accountable. This is a responsible plan for redeployment, not a precipitous withdrawal," said Senate Majority Leader Harry Reid.
"If the president refuses to change direction, America risks being bogged down in Iraq for years, not months."
Republicans dismissed the bill as a futile stunt, since although the Democrats control both houses of Congress, they do not have enough votes to overrule a presidential veto.
Nevertheless, it is a clear sign that Americans' elected representatives in Washington are deeply divided over the war in Iraq, says the BBC's Adam Brookes in Washington.
It is the first time Democrats have managed to summon the support to send a bill opposing Mr Bush's war directly to the president's desk.
George W Bush: 1
Bill Clinton: 38
George Bush Snr: 44
Ronald Reagan: 78
FD Roosevelt: 635
Thomas Jefferson: 0
The bill may be presented to him on Tuesday, the fourth anniversary of his speech declaring the battle of Iraq a "victory" in the war on terror.
That would be "the height of cynicism", said White House spokeswoman Dana Perino.
She confirmed that Mr Bush would use the presidential veto for only the second time in his two terms of office.
That is historically a very low figure, indicating how he benefited from a co-operative Congress, until Democrats seized control in November.
Mr Bush has described efforts to force a withdrawal as an attempt to "handcuff our generals".
Earlier, Gen Petraeus avoided giving a direct opinion on the bill, but said the US effort "clearly is going to require an enormous commitment over time".
He said the first few months of the Baghdad surge had led to improvements in Iraq, but said it had still to get fully into its stride, and admitted that progress was "often eclipsed by sensational attacks which overshadow our achievements".
He described the situation there as "exceedingly complex and very tough", and said "there is vastly more work to be done across the board".
Meanwhile, Iraqi Foreign Minister Hoshyar Zebari said "any premature timetable [for withdrawal] would not be realistic".
"This is part of the politicking, basically, in Washington and this has been damaging in fact to the security, political development, not only in Iraq, but in the entire region," he added.