HOUSTON — A federal judge in Texas struck down the state’s ban on same-sex marriage on Wednesday, ruling that the laws restricting marriage to a man and a woman violated the United States Constitution and handing gay-rights advocates a major legal victory in one of the nation’s biggest and most conservative states.

The judge wrote that the amendment to the state Constitution that Texas voters approved in 2005 defining marriage as between a man and a woman — and two similar laws passed in 1997 and 2003 — denied gay couples the right to marry and demeaned their dignity “for no legitimate reason.”

“Without a rational relation to a legitimate governmental purpose, state-imposed inequality can find no refuge in our United States Constitution,” wrote Judge Orlando L. Garcia of United States District Court for the Western District of Texas, in San Antonio.

While significant, Judge Garcia’s ruling will have no immediate effect on gay and lesbian couples wishing to marry in Texas. The judge issued a stay on his decision while the state appealed to the United States Court of Appeals for the Fifth Circuit, in New Orleans.