Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A federal judge on Wednesday declared Texas’ ban on gay marriage unconstitutional but left the ban in place while an appeals court considers the matter.

The judge, Orlando Garcia of U.S. District Court in San Antonio, wrote that the state’s marriage laws demean the dignity of gay couples “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,” the judge wrote.

The Texas ban was approved by voters in 2005 and passed with 76 percent of the vote. Two gay couples were challenging it — a Texas couple who wanted to marry and a couple who married in Massachusetts and wanted it recognized by Texas.

“What it really marks is one more voice — that of Judge Garcia’s — joining the chorus that is arising around the country on same-sex marriage and marriage equality,” Barry Chasnoff, a lawyer for the couples, told NBC News. “All our clients ever wanted was the right to be treated with respect and dignity and this judge says they should have it.”

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

One of the couples, Mark Phariss and Vic Holmes, said in a statement: “We are extremely happy — happy beyond words — with Judge Garcia's decision. Having been together almost 17 years, we look forward to the day when we can get married and when all gay Texans enjoy equal rights to marry as well.”

Texas Gov. Rick Perry, a Republican who was named as a defendant in the suit challenging the ban, vowed to “continue to fight for the rights of Texans to self-determine the laws of our state.”

“Texans spoke loud and clear by overwhelmingly voting to define marriage as a union between a man and a woman in our Constitution, and it is not the role of the federal government to overturn the will of our citizens,” he said in a statement. “The 10th Amendment guarantees Texas voters the freedom to make these decisions, and this is yet another attempt to achieve via the courts what couldn’t be achieved at the ballot box.”

Greg Abbott, the Republican attorney general and a candidate for governor, said that the state would appeal to the 5th U.S. Circuit Court of Appeals, in New Orleans.

Gay marriage is legal in 17 states and the District of Columbia, and nationwide public opinion polls consistently show a majority of people support it. Judges in Oklahoma and Virginia struck down gay-marriage bans in those states but left the bans in place pending appeal.

The judge wrote that his decision was not “in defiance of the great people of Texas or the Texas Legislature, but in compliance with the United States Constitution and Supreme Court precedent.”

The Supreme Court last year struck down the Defense of Marriage Act, the 1996 law that blocked federal recognition of gay marriage.

Attorney General Eric Holder told state attorneys general earlier this week that they are not obligated to defend gay marriage bans if the laws discriminate in a way forbidden by the Constitution.

Read Judge Garcia’s ruling here.

Are you a same-sex couple in Texas hoping to marry? How will the decision affect you? Share your story with reporter Miranda Leitsinger at miranda.leitsinger@nbcuni.com