Utah voters approved Amendment 3 to make it clear in the state constitution that marriage meant the legal union of one man and one woman.
Voters in some 30 other states have passed similar amendments.
In Utah, three same-sex couples challenged Amendment 3. The couples, represented by Peggy A. Tomsic and James E. Magleby, included two couples who want to marry in Utah and another pair who married elsewhere and want their union recognized in Utah.
State officials defended the amendment, saying man-woman marriage is held in particular regard by government because such couples naturally create children, and a mother-father home is "optimal" for raising children.
State officials also argued that it is a state's right to decide its marriage laws, a legal position upheld by the Supreme Court in its summer decision, which overturned part of the Defense of Marriage Act.
However, Judge Shelby rejected the line of reasoning about "procreation" as a reason to preserve marriage for heterosexual couples, especially when it violates the 14th Amendment rights of gay couples.
Friday's ruling in Utah comes on the heels of a ruling legalizing gay marriage from the New Mexico Supreme Court.
New Mexico became the 17th state to permit same-sex couples to marry. Gay rights activists want to see more than half the nation's population living in a "marriage equality" state by 2016.
Many gay-marriage 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.
This story is based in part on wire service reports.