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

The decision set off an immediate frenzy as the clerk in the state’s most populous county began issuing marriage licenses to gay couples while state officials took steps to appeal the ruling and halt the process.

Cheers erupted as the mayor of Salt Lake City led the state’s first gay wedding ceremony in an office building about three miles from the headquarters of the Mormon church. Dozens of other couples were lined up to get marriage licenses.

Deputy Salt Lake County Clerk Dahnelle Burton-Lee said the district attorney authorized her office to begin issuing the licenses but she couldn’t immediately say how many had been issued.

Just hours earlier, U.S. District Judge Robert J. Shelby issued a 53-page ruling saying the constitutional amendment Utah voters approved 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.

The decision drew a swift and angry reaction from Utah leaders, including Republican Gov. Gary Herbert.

“I am very disappointed an activist federal judge is attempting to override the will of the people of Utah. 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,” Herbert said.

The ruling also thrust the judge into the national spotlight less than two years after Congress approved his nomination to the federal bench. Shelby was appointed by President Barack Obama after GOP Sen. Orrin Hatch recommended him in November 2011.

Ryan Bruckman, a spokesman for the Utah attorney general’s office, said the office was asking for an emergency stay that would stop marriage licenses from being issued to same-sex couples during an appeal.

He said attorneys were drafting documents to be filed in court Friday afternoon. Louise York, the chief deputy clerk in the U.S. District Court of Utah, says the attorney general’s office can file electronically and a stay could be issued Friday night or Saturday.

Many similar challenges to same-sex marriage bans are pending in other states, but the Utah case 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.

The church said in a statement Friday that it stands by its support for “traditional marriage.”

“We continue to believe that voters in Utah did the right thing by providing clear direction in the state constitution that marriage should be between a man and a woman, and we are hopeful that this view will be validated by a higher court,” the church said.

The Utah 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.

If the ruling stands, Utah would become the 18th state to allow gay marriages, said Jon Davidson, director of Lambda Legal, which pursues litigation on LGBT issues nationwide. That’s up from six before the U.S. Supreme Court last summer struck down part of the Defense of Marriage Act that defined marriage as between a man and a woman. The District of Columbia also allows same-sex marriage.