Idaho's top court on Monday ruled that state law allows a woman to adopt the children of her same-sex spouse, in a precedent-setting victory for gay couples in a socially conservative U.S. state that has banned the unions.

The ruling stems from an adoption petition filed last year by an Idaho woman shortly after her marriage in California to her same-sex partner, the parent of boys ages 12 and 15, legal records showed.

The woman, unidentified in court documents on confidentiality grounds related to adoption, sought to share parental rights with her long-term partner. She appealed a magistrate judge's rejection of her petition.

The Idaho Supreme Court, in a unanimous decision reversing the lower court's ruling, said a person's gender or sexual orientation was not part of the legal criteria that allowed a minor to be adopted by an in-state adult resident.

"Any adult person" is defined as any human being over the age of 18 and "cannot possibly be construed to mean 'any married adult person' as the magistrate ultimately determined," Idaho Supreme Court Justice Jim Jones wrote for the court.

The ruling comes amid advances for gay couples in the U.S. and opposition by religious groups and others over the definition of marriage and the well-being of children raised by same-sex couples.

Neighboring Nevada dropped its defense of a state ban on gay marriage on Monday, saying the U.S. legal landscape had changed and its arguments in support of a voter-approved ban on same-sex nuptials were no longer sustainable.

Four Idaho lesbian couples filed a lawsuit last year in U.S. District Court challenging the state's constitutional ban on same-sex marriage. There has not been a substantive ruling in that case.

Ada County Magistrate Cathleen MacGregor Irby cited Idaho's constitutional definition of a legal domestic union as between one man and one woman in rejecting the woman's adoption petition last summer, legal records show.

The woman appealed to the Idaho Supreme Court, successfully arguing that her marital status was immaterial under Idaho adoption laws.

The magistrate judge mistakenly ruled marriage and adoption statutes "somehow relate to the same subject matter" and failed to apply the literal words of the state's adoption law as required, Jones wrote.

The justices' reversal of the lower court decision requires MacGregor Irby to hold a new adoption hearing.

(Reporting by Laura Zuckerman in Salmon, Idaho; Writing by Eric M. Johnson in Seattle; Editing by Andrew Heavens)