The US state of Massachusetts has ruled that same-sex couples are legally entitled to marry.
The issue came to court after seven gay couples filed a lawsuit
Massachusetts could become the first state to recognise gay marriage.
But the Supreme Judicial Court stopped short of ordering that marriage licences be issued to seven gay couples who challenged the law.
President George W Bush said the ruling violated the concept of marriage as a sacred institution and vowed to work with Congress to defend it.
Gay marriage is banned in the US, but Vermont and California have enacted laws which give same-sex couples the rights of traditional marriages.
The Massachusetts court ruled that barring same-sex couples from the benefits of civil marriage was "unconstitutional."
"Marriage is a vital social institution. The exclusive commitment of two individuals to each other nurtures love and mutual support. It brings stability to our society," Chief Justice Margaret Marshall wrote in the long-awaited ruling.
The 4-3 ruling means the issue will now return to the state legislature, which has 180 days to come up with a solution.
The issue came to court as the result of a lawsuit filed in 2001 by seven gay couples
who sued the Massachusetts Department of Public Health after they were refused marriage licenses.
Courts in Hawaii, Alaska and Vermont have also previously ruled that banning same-sex marriage was unconstitutional, but no state has yet issued marriage licences to gay couples.
In Hawaii and Alaska, the rulings were followed by the adoption of constitutional amendments limiting marriage to heterosexual couples.
In 2000, Vermont's state legislature approved civil unions for same-sex couples, giving them many of the same legal benefits of married couples.
Conservative groups and politicians opposed to homosexuality have been pressing for a constitutional amendment that would ban same-sex marriages outright.
The bill, which has 96 sponsors in the House of Representatives, seeks to enshrine marriage as a union exclusively between one man and one woman, and would make same-sex unions a legal impossibility.
President Bush does not believe in gay marriage, although he said recently that a constitutional amendment was not yet necessary.
Following the ruling he issued a statement saying: "Marriage is a sacred institution between a man and a woman."
He said he would work with congressional leaders and others to "do what is legally necessary to defend the sanctity of marriage".
Earlier this year, the US Supreme Court overturned a ban on sodomy in Texas, essentially making it illegal for any state legislature to outlaw gay sex.
In November, the country's first openly gay bishop was formally consecrated in New Hampshire.
Bishop Gene Robinson has a long-term male partner, and his appointment has divided the Anglican Communion worldwide.
Gay marriages are legal in neighbouring Canada, as well as in Belgium and the Netherlands.