A federal judge on Wednesday struck down a ban on gay marriage in Texas, a socially conservative state where people are less receptive to same-sex marriage than the nation as a whole.

So how did it happen? In ruby red Texas of all places?

The answer is that that as gay marriage advocates have shifted attention to the courts, judges are playing an increasingly influential role in the battle over marriage. What happened Wednesday is a fresh sign that the national shift toward clearing the way for gay marriage isn't limited to socially liberal states as legal challenges have taken center stage in the battle over marriage laws.

The decision speaks to the increasing influence of the courts in the debate over gay marriage. Judges are the emerging focal points as they can influence the law even in states where lawmakers aren't making big pushes to clear the way for gay marriage and referenda aren't cropping up like they did in many of the states that have legalized gay marriage in recent years.

Wednesday's ruling in Texas -- where the state's ban was challenged by two gay couples -- follows rulings in Virginia, Oklahoma, Utah, California and Kentucky where bans were also struck down by judges. The head of Freedom to Marry, an organization working to legalize gay marriage nationwide, said it's all part of a strategy to lay the groundwork for an eventual ruling by the highest court in the land.

"Freedom to Marry's strategy from the beginning has been to set the stage for the Supreme Court to bring the country to national resolution," says Evan Wolfson, president and founder of the group.

The group hopes to usher along one of 47 lawsuits in 25 states all the way up to the high court, with the hope that a decision could come as early as next year. The Supreme Court may, of course, choose not to take on any of the cases, in which case the group plans to continue its fight.

That a gay marriage ban has been struck down in Texas is a striking development considering how different marriage attitudes there are from the rest of the country: About three in 10 Texans (32 percent) said they supported allowing gay and lesbian couples to marry, according to the 2012 American National Election Study. Nationally, 41 percent of Americans said they supported it.

Opposition to a legal recognition of gay marriage is also higher in Texas (31 percent) than it is nationally (26 percent). Opinions about whether civil unions but not marriage should be allowed run about even.

More recent data show that Texas ≠America as a whole when it comes to gay marriage. A December 2013 poll from The Public Religion Research Institute showed that 48 percent in Texas favored allowing gay and lesbian couples to marry legally while 49 percent opposed. That compared with a national rate of 53 percent in favor to 41 percent opposed.

In short, even as attitudes nationally have shifted dramatically toward embracing gay rights during the past decade, there are plenty of states, like Texas, where opinions don't mirror the broader attitude. What Wednesday showed is that even in these states, the laws may change.

Still, these changes will continue to encounter stiff criticism from opponents of gay marriage. Texas conservatives led by the state's top Republican swiftly criticized Wednesday's decision, signaling the stiff push back that is sure to surface in the GOP-dominated Lone Star State in the coming days.

"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," said Gov. Rick Perry (R) in a statement.

State Attorney General Greg Abbott (R), a staunch social conservative who is also running for governor, is expected to appeal the judge's ruling. The judge has stayed the decision because of the likely appeal. That means gay couples will not be able to marry right away.

But for now, gay marriage advocates have scored a major win in an unlikely setting.

Peyton M. Craighill and Niraj Chokshi contributed to this post.