The vote -- like one on a similar bill in the House of Representatives a day earlier -- fell far short of the two-thirds margin needed to overturn President George W. Bush's likely veto.
The Iraq war legislation represented the biggest showdown yet with the White House by the Democratic-controlled Congress.
The $124 billion bill would require troop withdrawals to begin October 1, or sooner if the government Baghdad should fail to meet certain benchmarks.
The Senate passed the measure on a 51-46 vote. The House passed it on April 25 by a 218-208 vote.
Following the vote, the White House reiterated Bush's veto pledge.
Veteran Democratic Senator Robert Byrd of West Virginia, the chairman of the Senate Appropriations Committee, said Bush has failed in his mission to bring peace and stability to the people of Iraq. Byrd said it was time to bring U.S. troops home from Iraq.
A day earlier, House Speaker Nancy Pelosi spoke about the reason for the House vote.
"By placing an unacceptable strain on our military, this war is undermining our ability to protect the American people," she said. "Instead of making the American people safer, the war in Iraq has weakened our ability to protect our nation from the threat posed by international terrorism."
Pelosi urged Bush "to sign the bill so that we can focus on winning the war against terrorism, which is the real threat to the American people."
Democrats say they are encouraged by the release of a new poll that shows that a majority of Americans side with them on the issue and believe victory in Iraq is no longer possible.
According to the latest NBC News/"Wall Street Journal" poll, 56 percent of those questioned said they agreed with setting a deadline for troop withdrawal. Meanwhile 37 percent sided with Bush in opposing the move.
John Boehner, the Republican minority leader in the House of Representatives, was one of those who made the case against setting any withdrawal deadlines.
"We can walk out of Iraq, just like we did in Lebanon, just like we did in Vietnam, just like we did in Somalia, and we will leave chaos in our wake," he said.
The commander of US forces in Iraq, General David Petraeus, also met lawmakers to argue against the bill.
Veto Showdown Looms
Bush has repeatedly threatened to veto the bill.
"Congress's failure to fund our troops on the front lines will mean that some of our military families could wait longer for their loved ones return from the front lines, and others could see their loved ones headed back to the war sooner than they need to," Bush said earlier this month. "That is unacceptable to me, and I believe it is unacceptable to the American people."
Although the Democrats control both houses of Congress, they do not have enough votes to overrule a presidential veto.
Shifting U.S. Opinion On The War
RFE/RL visited a town in Maryland to gauge U.S. opinion about the conflict in Iraq. more
U.S. President George W. Bush says Congress must "meet the needs of our military on time, in full, and with no strings attached." more
THE COMPLETE STORY:
RFE/RL's complete coverage of events in Iraq and that country's ongoing transition.