A New York appellate court ruled Friday that valid out-of-state marriages of same-sex couples must be legally recognized in New York, just as the law recognizes those of heterosexual couples solemnized elsewhere. Lawyers for both sides said the ruling applied to all public and private employers in the state.

Even though gay couples may not legally marry in New York, the appellate court in Rochester held that a gay couple’s 2004 marriage in Canada must be respected under the state’s longstanding “marriage recognition rule,” and that an employer’s denial of health benefits had discriminated against the couple on the basis of their sexual orientation.

“The Legislature may decide to prohibit the recognition of same-sex marriages solemnized abroad,” a five-judge panel of the Appellate Division of State Supreme Court ruled unanimously in rejecting a 2006 lower court decision. “Until it does so, however, such marriages are entitled to recognition in New York.”

For more than a century, the court noted, New York State has recognized valid out-of-state marriages. Moreover, it said that the Court of Appeals, the state’s highest judicial body, has said the Legislature may enact laws recognizing same-sex marriages. “In our view, the Court of Appeals thereby indicated that the recognition of plaintiff’s marriage is not against the public policy of New York,” the court held.