A federal judge struck down Utah's same-sex marriage ban Friday in a decision that brings a nationwide shift toward allowing gay marriage to a conservative state where the Mormon church has long been against it.

Within hours, the county clerk's office in Salt Lake City began issuing marriage licenses to same-sex couples, after an order from a district attorney. One groom live-tweeted his wedding almost immediately.

Me and my new husband!! My polygamous Mormon great grandparents would be so proud! pic.twitter.com/82xyh9GJoS — Seth Anderson (@jsethanderson) December 20, 2013

US district judge Robert J Shelby issued a 53-page ruling Friday saying Utah's law passed by voters in 2004 violates gay and lesbian couples' rights to due process and equal protection under the 14th amendment.

Shelby said the state failed to show that allowing same-sex marriages would affect opposite-sex marriages in any way.

"In the absence of such evidence, the State's unsupported fears and speculations are insufficient to justify the State's refusal to dignify the family relationships of its gay and lesbian citizens," Shelby wrote.

It was unclear what the immediate effect would be, because the state can still appeal. The Utah attorney general's office said it would issue a statement on the ruling later.

The ruling comes the same week New Mexico's highest court legalized gay marriage after declaring it unconstitutional to deny marriage licenses to same-sex couples. A new law passed in Hawaii last month now allows gay couples to marry there.

The ruling is the first on a state same-sex marriage ban since the supreme court last summer struck down part of the Defense of Marriage Act, which stipulated that marriage was between a man and woman.

During a nearly four-hour hearing earlier this month in Salt Lake City, attorneys for the state argued that Utah's law promotes the state's interest in "responsible procreation" and the "optimal mode of child-rearing". They also asserted it's not the courts' role to determine how a state defines marriage, and that the supreme court ruling doesn't give same-sex couples the universal right to marry.

The lawsuit was brought by three gay and lesbian couples in Utah. One of the couples was legally married in Iowa and wants that license recognized in Utah.

Many similar court challenges are pending in other states, but Utah's has been closely watched because of the state's history of staunch opposition to gay marriage as the home of The Church of Jesus Christ of Latter-day Saints.

Peggy Tomsic, the attorney who represents the three couples, applauded Shelby's courage in making the ruling.

"We cannot capture in words the gratitude and joy plaintiffs feel," Tomsic said in a statement.

But she warned that the legal fight is not over, saying she expects the state to appeal the decision to the 10th US Circuit Court of Appeals.

During this month's hearing, Tomsic contended marriage is a fundamental right protected by the US constitution. She said the case embodies the civil rights movement of our time, saying discrimination has gone on long enough.

She said Utah's law, which passed with two-thirds of the vote, is "based on prejudice and bias that is religiously grounded in this state."