On a visit to New Mexico over Memorial Day weekend, I dropped in on a college friend who’s running for state treasurer. I expected his campaign would be a sleepy affair, all about pension boards and rainy-day funds.

Instead, the race for the Democratic nomination was attracting front-page attention as the candidates traded allegations over same-sex marriage — an issue that has about as much relevance to being state treasurer of New Mexico as a candidate’s position on North Korea.

Two weeks ago, my friend, Albuquerque lawyer John Wertheim, launched a barrage of TV ads saying his opponent, former state senator Tim Eichenberg, “sided with Republicans to prevent equality for gay couples.”

The issue exploded, and Wertheim has become a minor celebrity in the gay and lesbian community. “Whoa, this is good,” said gay-rights lobbyist Linda Siegle, who with her partner was one of the first same-sex couples to be married in New Mexico. Gay New Mexicans are abuzz, Siegle told me, even though “nobody really knows what the treasurer does, anyway.”

Eichenberg says that he has always been for marriage equality and that Wertheim’s accusation, based on a procedural vote in a legislative committee four years ago, is a mischaracterization. He has fought back, attending a Memorial Day dedication of a monument to lesbian, gay, bisexual and transgender service members. But he agrees that the issue has changed the race. “When your opponent continues to hammer this and misrepresent it the way he does, I think people do take notice,” he told me. “I mean, he’s on TV 20 times a day.”

We’ll know after Tuesday’s primary whether the gambit worked, or whether Wertheim’s negative campaigning (which has been criticized by newspapers and the state Democratic chairman) produced a backlash. But whatever the outcome, the race is another example of how dramatically the calculations on the issue have changed in just a couple of years.

Not long ago, supporting same-sex marriage was a principled but perilous position, even for Democrats, who stood to lose more moderate voters than they gained in the gay community. But rapidly shifting public opinion has turned that calculation upside down. Not only do virtually all Democratic (and a good number of Republican) office seekers now bless gay marriage, but many are taking the offensive on the issue as opponents beat a hasty retreat.

The Human Rights Campaign has been tracking the swing: In Colorado, embattled Republican Rep. Mike Coffman, who opposed the repeal of “don’t ask, don’t tell,” has announced his support for the Employment Non-Discrimination Act; in New York, GOP Rep. Chris Gibson, being challenged by an openly gay Democrat, became a co-sponsor of ENDA; and in Illinois, former Republican Rep. Robert Dold, who in 2011 said he supported the Defense of Marriage Act, has embraced marriage equality in an effort to win back his seat.

Polls continue to show record levels of support for marriage equality -- 59 percent to 34 percent in a March Washington Post-ABC News survey, roughly the inverse of a decade earlier -- with a majority of young Republicans now in support.

Since last year’s favorable Supreme Court rulings, bans on same-sex marriage have been struck down in 13 states, including Pennsylvania, where GOP Rep. Charlie Dent declared recently that “life is too short” to stand in the way of gay marriage. In Wisconsin, Gov. Scott Walker, a prospective Republican presidential candidate, softened his support for his state’s marriage ban. Even Arkansas started issuing licenses for same-sex marriage.

The situation is similar in New Mexico, where the Republican governor, Susana Martinez, abandoned her opposition to gay marriage earlier this year, calling it “the law of the land.” Amber Royster, executive director of Equality New Mexico, told me that she doesn’t know of a single Democratic office seeker who opposes gay marriage, and “I don’t think you’ll find many Republicans.”

By contrast, just five years ago, 10 of the 17 Democratic state senators joined with all 15 Republicans in voting down a bill giving legal rights to domestic partners. As it happens, treasurer candidate Eichenberg was one of those in support of the bill in 2009. But the next year, he cast a vote that effectively killed a similar bill in committee. Citing its possible costs, he joined Republicans in a 5-4 vote to send the bill to another committee, where it faced certain death.

At the time, the New Mexico affiliate of Howard Dean-founded Democracy for America called Eichenberg a “traitor to Democratic values.” But it was a politically sound vote back then — before the politics of same-sex marriage changed with unimaginable speed.

Twitter: @Milbank

Read more from Dana Milbank’s archive, follow him on Twitter or subscribe to his updates on Facebook.