The Senate on Thursday passed the Iraq war spending bill 51-47 after President Bush said he would likely veto the legislation over the inclusion of a timetable for withdrawal of U.S. troops.

The $122 billion emergency supplemental bill funds the wars in Iraq and Afghanistan but would require Bush to comply with orders to start bringing troops home from Iraq within four months, with a nonbinding goal of ending combat operations by March 31, 2008.

Sen. Richard Shelby, R-Ala., who voted against the legislation, said political infighting had led to naming "the date for defeat in Iraq."

"We’ve taken a step backwards,” he said after the vote. “It is the wrong message at the wrong time, surely this will embolden the enemy, it will not help our troops in any way.”

Click here to see how your senator voted.

Forty-eight Democrats and independent Sen. Bernard Sanders of Vermont voted in support of the measure, including Republican Sens. Chuck Hagel of Nebraska and Gordon Smith of Oregon. Sen. Joe Lieberman, I-Conn., and 46 Republicans voted against the legislation. Sens. Mike Enzi, R-Wy., and Tim Johnson, D-S.D., did not vote.

Senators must still go to a conference with House members to settle differences in the two versions of the bill.

Prior to the vote, Bush asked House Republicans for help in getting a bill that he can sign.

"We stand united in saying loud and clear that when we’ve got a troop in harm’s way, we expect that troop to be fully funded," Bush said after meeting with GOP lawmakers in the East Room of the White House. "We got commanders making tough decisions on the ground, we expect there to be no strings on our commanders. And we expect a Congress to be wise about how they spend the people's money."

Senate Republicans tried to slow the inevitable final vote by forcing votes on some pork projects attached to the supplemental that are unrelated to war spending, including emergency funding for spinach growers.

Sen. Jim DeMint, R-S.C., said a tree assistance funding provision has "no business" being in a war supplemental bill.

The final vote on the bill comes after the Senate agreed 50-48 to uphold the withdrawal language, and the House passed similar legislation. The House last week approved a more sweeping measure, including a mandatory withdrawal deadline for all combat troops before September 2008.

"We've spoken the words the American people wanted us to speak," said Senate Majority Leader Harry Reid, D-Nev. "There must be a change of direction in the war in Iraq, the civil war in Iraq."

Reid and House Speaker Nancy Pelosi sent Bush a letter Wednesday, requesting a meeting to discuss the legislation.

"This Congress is taking the responsible course and responding to needs that have been ignored by your administration and the prior Congress," Pelosi and Reid wrote in the letter.

Reid said the ball was now in the president's court.

"The Senate and the House have held together and done what we've done," he told reporters. "It's now in his corner to do what he wants to do."

The legislation is the Senate's first bold challenge of Bush's war policies since Democrats took control of Congress in January. With Senate rules allowing the minority party to insist on 60 votes to pass any bill and Democrats holding only a narrow majority, Reid had been unable to push through resolutions critical of the war.

This latest proposal was able to get through because Republicans said they knew the president would veto it.

"I think the sooner we can get this bill ... down to the president for veto, we can get serious about passing a bill that will get money to the troops," said Minority Leader Mitch McConnell, R-Ky.

Democrats acknowledge they do not have enough support in Congress to override Bush's veto, but say they will continue to ratchet up the pressure until he changes course.

Bush said the money is needed by mid-April or else the troops will begin to run out of money, but some Democrats say the real deadline is probably closer to June.

Gen. Peter Pace, chairman of the Joint Chiefs of Staff, told the House Defense Appropriations Committee Thursday that a delay in funding would have a chain reaction that could keep units in Iraq longer than planned.

If the bill is not passed by May 15, he said the Army will have to cut back on reserve training and equipment repairs, possibly delaying the formation of new Army units to relieve those deployed.

FOX News' Molly Hooper and The Associated Press contributed to this report.