Democrats said that the vote, in which the ban was defeated by 49 to 48 but needed 60 to pass, was merely an attempt by Republicans to rouse conservative supporters before congressional elections in November and divert to attention from presidential woes.
Republicans say the House of Representatives will take up the marriage amendment in July even though they do not expect it to get the two-thirds majority that a constitutional amendment requires for passage.
The mainly Republican senators who voted in favour of the ban said it was necessary to amend the constitution to prevent judges from annulling existing state bans on gay marriage.
But Democrats such as Edward Kennedy said it was designed to divert public attention from more important issues such as the war in Iraq.
"It is a cynical attempt to score political points by overriding state courts and intruding into individuals' private lives," he said on Tuesday.
Forty-five states have passed laws or amended their constitutions to prohibit same-sex marriage, and the 1996 Defence of Marriage Act allows states to refuse to recognise marriages performed elsewhere.
Several of those bans have been lifted by state judges and legal challenges are pending in nine states.
The bill's sponsor, Wayne Allard, a Republican, said judges would override what is in many states overwhelming public sentiment against gay marriage if the senate did not act.
"If we fail to define marriage, the courts will not hesitate to do it for us," Allard said.
Massachusetts is the only state to fully recognise same-sex marriages and 8,000 couples have been wed there since 2004.