New Hampshire Secretary of State Bill Gardner is shown in a meeting of the Presidential Advisory Commission on Election Integrity in Manchester, New Hampshire, Sept. 12, 2017. Credit: Holly Ramer | AP

New Hampshire’s longtime secretary of state, Bill Gardner, D, narrowly won his bid for a 22nd term on Wednesday, fending off a challenge amid a wave of anger among state legislators over his participation in President Donald Trump’s controversial voter fraud commission.

At a joint session of the New Hampshire state Senate and House of Representatives, Gardner won 209 votes to Colin Van Ostern’s 205, with one lawmaker casting a “scatter” vote for neither candidate.

Gardner’s win came in the second round of voting; the first round ended in a dramatic standoff, with Gardner taking 208 votes to Van Ostern’s 207 — both shy of the majority-plus-one needed for victory.

The win means Gardner, 70, will continue serving in the job he has held since 1976.

Gardner was greeted with a standing ovation from lawmakers after his win, according to Casey McDermott of New Hampshire Public Radio.

“Our state’s elections are so unique and so special, and that’s why the country pays attention when we’re on the national stage. … I’d like to ask all of you, particularly the new ones, I’m just down the hall, come in, I welcome any ideas — even modern ideas,” Gardner said, NHPR reported.

New Hampshire is one of three states where the secretary of state is elected by the legislature.

Gardner prompted an outcry among Democrats last year when, as a member of Trump’s now-disbanded commission, he gave what some critics viewed as a weak response to accusations that voter fraud may have been committed in the state in 2016.

“People are saying … there’s no fraud, and the others are saying there’s a lot of fraud,” Gardner said at the time in response to accusations made by the panel’s vice chairman, Kansas Secretary of State Kris Kobach, regarding college students’ use of out-of-state ID cards to vote. “And there might be no fraud; there might be a lot of fraud. But there’s no proof!”

The panel ultimately found no evidence of voter fraud and was disbanded in January amid mounting legal challenges. But Gardner defended his participation as recently as last month.

“I know some may never forgive me for having done that, but it was better that New Hampshire be represented than not,” he told reporters. “It’s better to be at the table than on the menu.”

Van Ostern seized on Gardner’s participation in the panel, as well as his support for GOP-authored legislation tightening voter registration requirements, in launching his bid against the incumbent.

Five former governors – Democrat John Lynch and Republicans Stephen Merrill, Craig Benson, John Sununu and Judd Gregg – took the unusual step of penning a letter last month backing Gardner and hailing his perspective as “one steeped in historical understanding, not partisan allegiance.”

“As the state’s top elections official, the Secretary of State is charged with safeguarding the integrity of the democratic process,” they said in the letter. “We have each witnessed Bill Gardner, regardless of the makeup of New Hampshire government, execute these duties with absolute independence and incorruptible motive.”

The letter prompted a response from Van Ostern, who noted that the secretary of state election was up to the 424 members of the state legislature, rather than governors “from decades past.”

“Sec Gardner’s 42 yrs deserve praise but his actions & judgement in this decade are not what they once were,” Van Ostern said in a tweet. “Time for accountable SoS who protects rights & liberties.”

Gardner is known nationally as the defender of New Hampshire’s status as first-in-the-nation primary state.

Washington Post writers John Wagner and David Weigel contributed to this report.