A US federal judge has ruled that Oklahoma’s ban on same-sex marriage violates the US Constitution, but stayed the effects of the ruling while the state’s courts decide how to proceed.

District Judge Terence Kern said that a law approved by voters in 2004 was “an arbitrary, irrational exclusion of just one class of Oklahoma citizens from a governmental benefit.”

The decision on the largely conservative southern state comes after a federal judge overturned a ban on same-sex marriage in the western state of Utah in early January.

Hundreds of couples had got married in Utah last year before the US Supreme Court intervened to stop weddings until the state’s courts sorted out the matter. The fate of gay marriage in Utah now rests in the hands of a federal appeals court in Denver.

Judge Kern cited the Utah situation in issuing the stay on his own ruling.

The constitutional amendment approved by Oklahoma voters says that marriage in the state consists only of the union of one man and one woman, a measure which Judge Kern said violates the US Constitution’s equal protection clause.

“Equal protection is at the very heart of our legal system and central to our consent to be governed. It is not a scarce commodity to be meted out begrudgingly or in short portions.

"Therefore, the majority view in Oklahoma must give way to individual constitutional rights,” Kern wrote.

Oklahoma Attorney General Scott Pruitt's office, which has supported the law, did not immediately have a comment on the ruling.

Mary Bishop and Sharon Baldwin, a couple from the Oklahoman city of Tulsa, filed a lawsuit along with another same-sex couple in November 2004, shortly after voters overwhelmingly passed the constitutional amendment.

The couples sought the right to marry and have marriage from other states recognised in Oklahoma.

Judge Kern said that the Bishop couple have “been in a loving, committed relationships for many years" and they should be recognised as a married couple “with all its attendant rights and responsibilities.”

27 US states, other than Utah and Oklahoma, constitutionally prohibit same-sex marriage. Four more states, Indiana, Pennsylvania, West Virginia and Wyoming do not permit it through state laws.