D. Bruce Hanes, the Montgomery County clerk, knows the state forbids issuing marriage licenses to gay couples. He's doing it anyway.

Gay marriages are illegal in Pennsylvania. But if you go to D. Bruce Hanes, you can get one anyway.

Hanes is an Army veteran and Democratic county clerk in Montgomery County, outside Philadelphia. In July, he started issuing marriage licenses to same-sex couples. Pennsylvanians Loreen Bloodgood and Alicia Terrizzi, 17-year partners who are the mothers of two sons, were first in line.

"Based on the recent Supreme Court decisions over the Defense of Marriage Act, I felt that Pennsylvania's Marriage Act was indeed unconstitutional," Hanes tells Mother Jones. "So in this office, we no longer ask people their gender." Since enacting the policy, Hanes' office has issued more than 160 licenses to same-sex couples. "Couples come from all over to Montgomery County to get the licenses," Hanes says.

Now a Pennsylvania state court has to decide whether what Hanes did was legal—and what to do about the licenses he already issued. Republican Gov. Tom Corbett's Department of Health has sued Hanes for failing to enforce Pennsylvania law, arguing that the marriage licenses are invalid. A hearing in the case is scheduled for Wednesday. The outcome of the suit will determine whether a single local official can cite federal precedent to decree a state's same-sex-marriage law unconstitutional.

It's not so far-fetched an idea, explains Karl Manheim, a professor at Loyola Law School in Los Angeles. Last week, Manheim notes, the IRS began to let same-sex couples file joint tax returns, regardless of whether they live in a state where same-sex marriage is legal. "We're soon going to have a proliferation of federal laws that treat [gay] folks as married," Manheim says. "The next battleground is whether states like Pennsylvania are going to be able to ignore this."

Corbett argues that allowing Hanes to continue issuing same-sex marriage licenses could set a dangerous legal precedent. "Regardless of where you might stand on the issue of same-sex marriage, the question being decided with this particular case is does any local official, anywhere, have the ability pick and choose statutes they want to follow?" says Nils Hagen-Frederiksen, a spokesman for the governor. "Individuals can't single-handedly be the interpreters of constitutional issues. That's problematic."

In a legal brief, the state's lawyers put the issue more bluntly: "Had the clerk issued marriage licenses to 12-year-olds in violation of state law, would anyone seriously contend that each 12-year-old…is entitled to a hearing on the validity of his 'license'?" Marriage equality advocates found this comparison particularly offensive: "We're talking about couples who have been together for decades, who have built families together, who have given back to communities across Pennsylvania. We're not talking about children," wrote Ted S. Martin, executive director for Equality Pennsylvania, in a statement. Hagen-Frederiksen says that Corbett has since acknowledged that comparing consenting gay and lesbian adults to 12-year-olds was inappropriate. But the controversy over the analogy, he argues, has distracted from a key legal point: "Marriages are registered in a uniform way. Right now we have 66 issuing one way and one county going another way. That's not uniform."

This isn't the first time a local clerk has flouted state law barring marriage of same-sex couples. Long before California passed its gay-marriage ban, Proposition 8, officials issued thousands of same-sex marriage licenses in defiance of state law. The California Supreme Court eventually put a stop to that practice, voiding the licenses. That could happen in Pennsylvania, too. But Hanes, who says he fully expected Corbett's Health Department to sue him, isn't at risk—as an elected official, he would have be impeached to be removed from office. Right now, that doesn't seem likely, especially since he's been getting so many thank-you notes. "I was getting 5-10 a day for a couple weeks," he says.

Even if the Pennsylvania court follows California's lead and deems Hanes' same-sex marriage licenses invalid, same-sex couples could still come away with a win, explains Sarah Warbelow, state legislative director for the Human Rights Campaign, a group that advocates for LGBT equality. If a same-sex couple wants to sue over a marriage license, they need to have what lawyers call standing—the ability to prove they were harmed. "There are circumstances where actions [like Hanes'] create that standing," Warbelow says.

Manheim, the law professor, thinks it's possible that federal agencies will recognize Hanes' same-sex marriages even if the Pennsylvania court rules against him. "The governor of Pennsylvania is fighting a losing battle," Manheim says. "The states have lost. Hanes may incur some legal expenses, but he will eventually prevail."

This piece first appeared in motherjones.com