Republican Jason Lewis topped DFLer Angie Craig for the open seat in Minnesota’s Second Congressional District on Tuesday ­— but only after an hourslong wait for results that stretched well into the early morning hours of Wednesday.

As results trickled in, Lewis took an early lead in a race that was expected to be one of the most competitive in the state. But the outcome wasn’t immediately clear: Results from Dakota County, which makes up a considerable percentage of the district, were delayed for hours because of what election officials later said was a “software glitch” in new voting equipment.

But by about 6 a.m., with the last results in, Lewis’ campaign declared victory. The former talk-radio host secured 47 percent of the vote, while Craig, a former executive at St. Jude Medical, took 45 percent. Independence Party candidate Paula Overby picked up most of the remaining 8 percent.

Lewis said Wednesday that he’s looking forward to getting started in Washington, D.C., particularly at a time when the same party will be running both Congress and the White House. He said he plans to make health care reform a top priority, and believes that his messages on that issue and others during the campaign helped propel him forward in a very competitive race.

“I think the voters are tired of politics as usual … and wanting someone to talk to them about how you’re going to fix this system, reform health care, all the issues they were concerned about, and not just focus on a negative campaign to win,” he said. “I think the Democrats missed the mark in not thinking there was something in the air this time.”

Craig’s campaign had attracted the support of the national Democratic Party, which had targeted the swing district — a place where voters twice picked President Obama and recently voted for Democratic senators — as a prime spot to flip a seat long held by Republican U.S. Rep. John Kline, who is retiring. Craig held a considerable fundraising advantage throughout the campaign, and frequently worked to link Lewis and his brash, on-air commentary with Republican presidential nominee Donald Trump.

In a statement Wednesday morning, Craig said she was proud of her campaign, her staff and her volunteers, and offered well wishes to Lewis.

“I want to congratulate Jason on his victory,” she said. “We may not agree on many things, but the one thing that we’ve always had in common is that we both worked diligently to share our vision of how best to fight for Minnesota families.”

Elsewhere, all seven incumbents looking to hold on to their congressional seats in Minnesota succeeded Tuesday night — but some did so only by the slimmest of margins, facing a wave of voters apparently looking to shake up the status quo.

In northeast Minnesota’s Eighth District, Rep. Rick Nolan, a Democrat, won by less than a single percentage point — a margin of 2,008 votes — over Republican Stewart Mills after what became the country’s most expensive congressional race.

“There are changes and challenges ahead, and I’ll continue to work with others in the Congress to find common ground and solutions for the Eighth District,” Nolan said after his win.

In southern Minnesota’s First District, where Trump completed a near-complete sweep, Democratic Rep. Tim Walz edged out a victory over Republican challenger Jim Hagedorn in similar fashion, winning by just 2,547 votes, or about three-fourths of a percentage point.

Elsewhere around the state, the margins of victory were larger. In the Third District, covering suburbs to the west, north and south of Minneapolis, four-term U.S. Rep. Erik Paulsen, a Republican, handily defeated Democratic challenger Terri Bonoff by a double-digit margin, taking nearly 57 percent of the vote to Bonoff’s 43 percent.

In St. Paul and Minneapolis’ Fourth and Fifth Districts, incumbent Democrats Betty McCollum and Keith Ellison also glided to wide victories. McCollum won nearly 58 percent of the vote, while her Republican challenger, Greg Ryan, took 34 percent. In the Fifth District, Ellison won the support of a full 69 percent of voters, while Republican Frank Nelson Drake received just over 22 percent of the vote.

Republican Rep. Tom Emmer secured a second term representing St. Cloud and northern Twin Cities suburbs in the Sixth District, winning nearly 67 percent of the vote over DFL challenger David Snyder, who took 34 percent.

Minnesota’s longest-serving congressman, DFLer Collin Peterson, who was first elected in 1990, secured another term representing Bemidji, Moorhead, Willmar and other communities in the Seventh District. He took 52 percent of the vote to Republican Dave Hughes’ 47 percent.