Granite State Democrats defied political gravity Tuesday, sweeping the federal elections and possibly winning control of the state House of Representatives, despite a midterm election environment that had all but guaranteed a good night for the GOP.

Instead, it was Democrats who had the upper hand in New Hampshire winning — and winning by big margins — despite the burdens of an unpopular president, decades-high inflation, and more than 70 percent of Granite Staters saying the country is on the wrong track.

Sen. Maggie Hassan handily won re-election over retired Gen. Don Bolduc by about 10 points, garnering 54 percent of the vote.

As The Washington Post’s Henry Olsen noted last weekend, “With the notable exceptions of Joe Manchin III (D-W.Va.) and Susan Collins (R-Maine), no Senate candidate since 2014 has run more than five points ahead of the job approval rating of their party’s president.”

Hassan is on course to outpace Biden’s 40 percent approval number by nearly 15 points.

In the First Congressional District, Republican Karoline Leavitt looked like a strong challenger, and polls consistently showed a neck-and-neck race with Rep. Chris Pappas. Instead, she trailed the incumbent by eight points, failing even to match the performance of fellow Republican Matt Mowers when he challenged Pappas two years ago.

And the Republican retreat reached down to the State House, too. Late Tuesday night, the GOP was in danger of losing control of the House and shrinking its majority in the state Senate. It was a reversal of the New Hampshire GOP’s surprise performance last year when they wrested control of the legislature from the Democrats even as Joe Biden carried the state by eight points.

Just 24 hours earlier, the midterm looked like a classic drubbing for the party in power. National polls showed Republicans with a consistent lead in the generic ballot number, and state polls showed momentum for New Hampshire’s GOP challengers. A University of New Hampshire poll released on Sunday declared the Senate and First Congressional District races “too close to call.”

With Republican Gov. Chris Sununu winning by around 14 points, the scene appeared set for GOP success.

Instead, Tuesday was a Republican debacle as Democrats won more races, and by bigger margins, than expected.

What happened?

Sources inside both the federal and state GOP campaigns all had the same, one-word answer: Abortion.

“We were breaking midterm turnout targets, but she [Hassan] was hitting 2016 turnouts in some of her key towns,” a source close to the Bolduc campaign said. “It was amazing.”

In Concord, for example, Sen. Jeanne Shaheen got 3,539 votes two years ago in a presidential year, when turnout is far higher than a midterm. On Tuesday, Hassan got 5,070 votes.

And while some GOP insiders also pointed to a weak state party organization and lack of a ground game (“The RNC ground operation has turned into a Twitter posting program,” one consultant groused), they all agreed the engine to turnout numbers like these was the abortion issue.

“It’s all about abortion,” a longtime NHGOP operative said. “The pro-lifers got what they wanted and the whole party paid the price. Abortion is going to be for us what the state income tax issue is for Democrats.”

Another problem, according to campaign sources, was the so-called “candidate quality” issue, which even fans of Bolduc and Leavitt admitted was a challenge. New Hampshire rarely votes red at the federal level and asking those voters to support solidly MAGA Republican candidates who embraced Trump’s views on the 2020 election was a bridge too far.

Bolduc’s 10-point defeat got the attention of analysts on Fox News covering Tuesday night’s returns, with several panelists expressing surprise at his relatively poor showing. But Mark Thiessen, a former George W. Bush speechwriter, used the performance of Bolduc, Arizona’s Blake Masters, and other Trumpian candidates to issue an indictment of his party.

“Think about this: We have the worst inflation in four decades. The worst collapse in real wages in 40 years. The worst crime wave since the 1990s. The worst border crisis in U.S. history. We have Joe Biden, who is the least popular president since Harry Truman… and there wasn’t a red wave,” Thiessen said.

“That is a searing indictment of the Republican Party, a searing indictment of the message that we have been sending to the voters. They looked at all of that [bad news], and then looked at the Republican alternative and said, ‘No thanks.’

“This is an absolute disaster,” Thiessen added. “We need to look at who won today: Ron DeSantis, [Ohio Gov. Mike] DeWine, [Georgia Gov. Brian] Kemp. This is the path to the future. And electing these radical candidates who ran far behind them has put the Republican Party in a terrible position.”