Hillary Clinton narrowly won Minnesota Tuesday, despite losing 19 of the state’s counties that President Obama carried in the last election.

State officials didn’t call the nail biter for Clinton until just before dawn Wednesday.

Clinton held Democratic strongholds in the Twin Cities and northeastern Minnesota to capture 46.41 percent of the vote, but Donald Trump had strong support in outstate Minnesota and the outer fringe of the metro, pulling in 44.96 percent of voters.

About 9 percent of voters — the largest since 1992 — voted for someone other than Trump or Clinton.

The state has backed the Democrat for president going back to 1976, but Trump made a late play for support here, stopping Sunday at the Sun Country hangar at the airport for his first public rally in Minnesota.

Clinton won just nine counties, with wide margins in staunchly Democratic Hennepin, Ramsey, Cook and St. Louis counties. She narrowly won in Olmsted, Carlton, Washington, Lake and Dakota counties.

In many of the typically Democratic counties that Clinton either narrowly won or lost to Trump, the percentage of voters choosing other candidates was higher than the margin of victory. For example, in Winona County, Trump won by 3 percentage points, while 10 percent of voters selected someone other than Clinton or Trump.

Trump’s 45 percent is similar to how other Republican candidates have done in Minnesota in previous elections, but just shy of the 47 percent President Bush had in his 2004 re-election.

Minnesota was one of the only Midwestern state’s that Clinton carried, in an extremely close presidential race that saw Trump defy expectation and most late polls of the race.

As the results rolled in late Tuesday night, the mood at the DFL election night party in Minneapolis was anxious and edgy.

The mood was more upbeat at the Republican election party at Bloomington’s Radisson Blu, where roars went up as Trump was named the winner in Florida, North Carolina and other key states.

“Donald Trump is a man who’s worked his entire life for the economy,” said Alex Reynolds, a 19-year-old University of Minnesota student decked out in a suit for the GOP bash. He said he liked Trump because “he’s not a career politician, and he’s a businessman.”

Efforts by Democratic candidates to tie opponents to Trump also weren’t panning out. In the southwest Twin Cities suburbs, GOP U.S. Rep. Erik Paulsen held off a challenge by DFLer Terri Bonoff, who repeatedly tried to raise Trump as a campaign issue.

Two Democratic U.S. House incumbents, Rep. Rick Nolan in northeastern Minnesota and Rep. Tim Walz in the southern part of the state, held off strong Republican challenges. Before Tuesday night, Walz had never been seen as seriously in peril. And in the southeast Twin Cities suburbs, Republican Jason Lewis beat DFLer Angie Craig in a race to fill a seat vacated by a retiring Republican.

In the fight for control of the State Capitol, Republicans held on to their House majority and the DFL held onto the Senate.

Congressional and legislative races are historically heavily influenced by the top of the ticket in presidential years, but Clinton’s relatively weak standing in pre-election polls outside Minneapolis, St. Paul and their inner-ring suburbs gave Republicans hope of mitigating that effect.

Voter turnout always runs higher in presidential years, and at polling places around Minnesota on Tuesday, it was clear the presidential race was the main attraction for most voters.

“I love this country,” said Annoula Bahneman, voting Tuesday morning in St. Paul with her stepson Takis. They both went for Clinton.

Michael Solum, voting for Trump in Apple Valley, said he thinks too much was made of the possible downsides of a Trump presidency. “I'm not going to worry about the outcome,” Solum said. “The world will keep spinning.”

More than one immigrant voter cited worry at the prospect of Trump after he campaigned for months on building a wall along the Mexican border and cutting off the flow of Syrian refugees into the country.

“I have six kids. They were all born here,” said Amina Ahmed, who voted for Clinton in Apple Valley. “What Trump said is not good for immigrants.”

For many voters, distaste for one of the two candidates seemed to be the main driver in choosing the other. Some level of dislike for both candidates was a frequent refrain.

“I wish we had a better option,” said Susan Pawelko of Eagan, who voted for Trump. “I wish any of the other Republicans had been up against her. I don't like her, don't like her, don't like her.”

In Bloomington, Scott Bellefeuille was voting for the first time in his life, while his wife, Angela, only for the third time. They said they were inspired by their teenage daughters.

“If our kids can go vote, so should we,” Angela Bellefeuille said. "But we didn't vote the same as our children. We voted for Trump.”

That polarization, a main feature of this election, caused anxiety for some voters.

“It has been possibly the scariest campaign that I've ever experienced,” said Carol Longtine, a 77-year-old Minneapolis voter who said she reluctantly went for Clinton. “I'm very afraid of the results. I'm afraid of whichever one gets elected. I'm afraid of civil unrest.”

While the presidential race was on everyone's mind Tuesday, the outcome of the down-ballot races set the table for what's certain to be an eventful two years in Minnesota politics, with races in 2018 for the U.S. Senate seat held by DFL Sen. Amy Klobuchar and an open gubernatorial race following the planned retirement of DFL Gov. Mark Dayton. 

Staff writers Eric Roper, Mary Lynn Smith, Emma Nelson, Liz Sawyer, Shannon Prather, John Reinan and Miguel Otárola contributed to this report.