The state Supreme Court upheld a ban on gay marriage Wednesday, saying lawmakers have the power to restrict marriage to unions between a man and woman.

The 5-4 decision disappointed gay marriage advocates and left Massachusetts as the only state that grants full marriage rights to gay couples.

The decision was the latest in a series of significant court rulings favoring gay marriage opponents. New York's high court dealt gay couples another blow earlier this month when it ruled that a state law limiting marriage to between a man and a woman was constitutional.

In the Washington decision, the court overruled two lower courts that had found the state's 1998 Defense of Marriage Act, which limits marriage to opposite-sex couples, violated the state constitution and its Equal Rights Amendment.

Three of the justices in the majority, however, invited the state Legislature to take another look at the gay marriage ban's effect on same-sex couples.

"Given the clear hardship faced by same-sex couples evidenced in this lawsuit, the Legislature may want to re-examine the impact of the marriage laws on all citizens of this state," wrote Justice Barbara Madsen, with Justice Charles Johnson and Chief Justice Gerry Alexander concurring.

The two other justices in the majority, James Johnson and Richard Sanders, agreed with the outcome but more actively opposed gay marriage.

Johnson wrote that the Legislature had "a compelling governmental interest in preserving the institution of marriage, as well as the healthy families and children it promotes. This conclusion may not be changed by mere passage of time or currents of public favor and surely not changed by courts."

The four justices in the minority harshly criticized the ruling, with Justice Mary Fairhurst saying those in the majority had bowed to public opinion by upholding the law.

Nineteen gay and lesbian couples had challenged the constitutionality of the 1998 state law.

King County Executive Ron Sims, who helped foster one of the original lawsuits by same-sex couples seeking to marry in liberal Seattle, said his next step would be to push for civil unions.

"There's still hope in the long run," Sims said. "I still dream for a just society."

Forty-five states have laws banning gay marriage or limiting marriage to between a man and a woman. Congress recently rebuffed a move to get a constitutional amendment banning same-sex marriage.

In other recent rulings on the issue, courts reinstated voter-approved bans on gay marriage in Nebraska and Georgia, and Tennessee's Supreme Court ruled that voters there should have a say on allowing gay marriage.

Massachusetts' high court — the same court that issued the historic ruling that has allowed more than 8,000 same-sex couples since 2004 to marry in that state — ruled a proposed state constitutional amendment to ban gay marriage could go on the ballot if approved by the Legislature.

In Connecticut, a judge found gay and lesbian couples had not been harmed by that state's decision to grant them civil unions but not marriage. Vermont also allows civil unions that confer the same legal rights as heterosexual married couples.

Brenda Bauer of Seattle, who sued over the Washington state law along with her longtime partner Celia Castle, said it was a sad day for her family.

"I believe that our constitution should treat all of its citizens the same, and in this case the court was willing to treat my family differently than other families," Bauer said.

Gay marriage opponents said they were surprised, but grateful.

"This is more than we could have imagined," said Jon Russell, field director for the conservative Faith and Freedom Network, which participated in the case. "We are shocked, and pleasantly shocked. We were prepared for the other direction."