One of the few surprises in Tuesday’s primary election was that Brian Nieves wasn’t able to capture the nod for recorder of deeds on the Republican ticket.

Jennifer Metcalf, who currently works in the recorder’s office, defeated Nieves and three other candidates to win the GOP nomination.

Nieves, a state senator with 12 years of experience in the Legislature, had name recognition, a hefty campaign war chest and scores of fiercely loyal supporters. The conventional wisdom was he would walk to an easy win.

He lost by 1,338 votes or roughly 10 percentage points.

Many found it odd that Nieves, a firebrand and Tea Party stalwart, would forgo an opportunity to run for another term in the Senate to run for a local and largely administrative office like recorder of deeds. He wasn’t term-limited out and seemed to relish his role as a gunslinger for conservative causes. The mundane role of recorder of deeds didn’t seem like a natural transition for a lightning rod.

Still, Nieves appeared to be the odds on favorite to win the primary. So what happened?

Some point out Nieves didn’t work as hard this campaign as he has in the past. The usually tenacious campaigner was somewhat lackadaisical this round. He didn’t appear to have the usual fire in his belly. Metcalf outworked him, according to many political observers.

Others contend that voters may have grown weary of Nieves’ often over-the-top positions like his efforts to nullify federal gun laws. Perhaps a Nieves “fatigue factor” played a role in his defeat.

But another factor may have influenced the outcome of the race. The usually savvy and always opportunistic politician may have misjudged the Zeitgiest of the electorate regarding his main campaign plank — the defense of traditional marriage.

It was a stretch to inject the issue of gay marriage into a local campaign. Nieves presented the issue in a constitutional context but people saw it for what it was — a base attempt to use a wedge issue to politicize the office.

While it’s true that the gay-marriage battle is being waged across the nation, it isn’t a burning issue in Franklin County. Moreover, as Maggie Haberman pointed out this week in Politco, public opinion polls on the issue of gay marriage have moved swiftly over the past decade, when George W. Bush was re-elected amid ballot initiatives that banned same-sex nuptials as a method of boosting turnout among conservatives.

It’s too early to write the political epitaph for Brian Nieves. But he misfired using gay marriage in his campaign for recorder of deeds.