A federal judge has struck down Utah's ban on gay marriage, saying that the western state's law - approved by voters in a referendum in 2004 - violates the US constitution.

District Judge Robert Shelby, ruling in a lawsuit brought by three gay couples, said the state's law conflicts with the right of same-sex couples to equal protection under the 14th Amendment to the constitution.

"The state's current laws deny its gay and lesbian citizens their fundamental right to marry and, in doing so, demean the dignity of these same sex couples for no rational reason," he said on Friday.

"Accordingly, the court finds that these laws are unconstitutional."

The ruling was a major victory to gay rights activists in the conservative state where the Mormon church wields considerable influence.

It also marks an ongoing nationwide shift towards allowing gay marriage. Neighbouring New Mexico became the 17th US state to legalise same-sex marriage on Thursday.

Impromptu weddings

Salt Lake County Deputy Clerk Dahnelle Burton-Lee said the district attorney authorised her office to begin issuing marriage licenses to same-sex couples on Friday.

A festive atmosphere broke out in the county government building that played host to a string of impromptu weddings - including that of a state senator to his longtime partner.

But a spokesman for the state's Attorney General's office said lawyers would seek an emergency stay of the judge's order while the office appealed to a higher court.

"I am very disappointed an activist federal judge is attempting to override the will of the people of Utah," said Utah Governor Gary Herbert. "I am working with my legal counsel and the acting attorney general to determine the best course to defend traditional marriage within the borders of Utah."

Marriage laws are governed by individual US states, nearly 30 of which have amended their constitutions to ban same-sex marriage.

Efforts to give same-sex couples the same rights as heterosexuals have gathered steam in recent years.

One of the most important victories came in June when the US Supreme Court struck down the Defence of Marriage Act, which defined marriage as a union between one man and one woman.