California's Supreme Court opened the way on Thursday for gay marriage opponents to defend California's same-sex marriage ban in federal court, writing that the state's constitution backed their case.

The ban in the most populous U.S. state has been in legal limbo over a technical but crucial debate: whether citizens can defend a ballot initiative if elected officials choose not to. The court said they could.

Former Governor Arnold Schwarzenegger and state Attorney General Jerry Brown, who is the current governor, had declined to defend the gay marriage ban after it was passed in a state-wide voter initiative in 2008.

If proponents of the ban were not allowed to defend it, then it necessarily would have lost any legal challenge.

The legal battle over the ban is widely expected to reach the U.S. Supreme Court, which then could rule on whether there is a federal constitutional right for same-sex couples to marry.

More than 40 U.S. states have outlawed same-sex marriages in measures such as California's voter initiative, known as Proposition 8.

The 9th U.S. Circuit Court of Appeals had asked the top state court to opine on the technical issue, although it is not legally bound to follow the lead of the California court, which was unanimous in Thursday's decision.

State Supreme Court justices had telegraphed their decision in a September hearing where some scoffed at the idea that a voter initiative was doomed if elected officials chose not to defend it.

(Reporting by Peter Henderson and Dan Levine)