SALT LAKE CITY — 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 one of the state’s first gay-wedding ceremonies in an office building about three miles from the headquarters of The Church of Jesus Christ of Latter-day Saints. 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.

Hours earlier, U.S. District Judge Robert Shelby issued the 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.

Save 75% on a Digital Subscription Today

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,” he wrote.

The decision drew an 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,” he said. The state filed a notice of appeal late Friday and was working on a request for an emergency stay that would stop marriage licenses from being issued to same-sex couples.

The Utah case has been closely watched because of the state’s history of staunch opposition to gay marriage as the home of the Mormon church, which opposes gay marriage.

The Utah ruling came the day after New Mexico’s highest court legalized same-sex marriage.