As Iowa Republicans gathered at a Hilton ballroom in downtown Des Moines on Tuesday to watch election results play out on FOX News, party leaders took the stage to help boost spirits.

Early on, results showed Democrats flipping the U.S. House seats in Iowa's 1st and 3rd Congressional Districts. And Democratic businessman Fred Hubbell maintained an early lead against Republican Gov. Kim Reynolds in the hotly contested governor's race.

U.S. Sen. Joni Ernst, R-Iowa, encouraged supporters to hang tight, recalling her 2014 race against Bruce Braley, who was predicted to win early as the votes from "urban folks" came in first.

"We have a lot of those rural communities that really support our conservative efforts, so I want you to keep that in mind as we move through the night," Ernst said.

Ernst was correct: The landscape began to shift shortly before 11 p.m., when rural votes trickled in and Reynolds took the lead for the first time. She held onto it for the remainder of the night.

With her win, Reynolds became Iowa's first woman elected governor.

► More:Republicans retain control of Iowa House and Senate, as well as legislative agenda

Her supporters had the loudest response of the night when Lt. Gov. Adam Gregg introduced her as such.

"With the help of all of you tonight, Gov. Kim Reynolds proved that there is no more glass ceiling under that golden dome," he said.

Polls had shown respective support for Reynolds and Hubbell falling within the margin of error in the final days of the campaign. And that's how it ended up: the tightest margin in an Iowa governor's race in 62 years.

It was also the most expensive governor's race in Iowa's history: The two candidates spent about $35 million combined.

These four Iowa counties show how the governor's race was won and lost.

► Election Day 2018 Maps: Results for Iowa governor, U.S. House, state Senate, state House

► More:Iowa Democrats stunned, confused after Fred Hubbell loses, but others make big gains

Winneshiek County

This northeast Iowa county had the tightest margin in Tuesday's gubernatorial race. Reynolds won Winneshiek by 0.6 percent, according to unofficial results.

Across the state, Reynolds and Hubbell put up lopsided performances in many of Iowa's 99 counties. But Winneshiek's razor-thin margin was more indicative of the close statewide race.

"It was definitely high turnout," said Winneshiek County Auditor Benjamin Steines. "We had only about 1,500 ballots fewer than for the presidential race in 2016."

But it wasn't necessarily the governor's race that drove voters to the polls: Steines said interest in the 1st Congressional District race and the Iowa House District 55 seat seemed to be driving much of the traffic to the polls.

Across the state, Reynolds beat Hubbell by 3 percentage points — the smallest margin of victory in the Iowa governor’s race since 1956, when Democrat Herschel Loveless defeated incumbent Republican Leo Hoegh 51.2 percent to 48.8 percent, according to Iowa secretary of state data.

While it was an unusually tight race across the state, the close finish in Winneshiek County wasn't a surprise to Steines. He said the county often trends "purple," with voters in Decorah frequently supporting Democrats and voters in the rural part of the county supporting Republicans.

In fact, Tuesday's results were mixed: Democratic congressional candidate Abby Finkenauer won the county by more than 7 percentage points, and the Iowa House race remained undetermined Wednesday; only eight votes separated the Republican candidate from the Democrat, and it's possible that dozens of absentee ballots are still outstanding.

"It’s not unusual for us. That’s normal," Steines said. "That’s happened several times for the last 10 to 12 years."

Story County

Hubbell won one of his most decisive victories in Story County, where he beat Reynolds by 20 percentage points.

But his margin of victory was dwarfed by that of Democratic congressional candidate J.D. Scholten: In Story County, home to Iowa State University, Scholten beat King by 33 points.

That was indicative of a wider trend: Democratic congressional candidates performed better than Hubbell in 85 of Iowa's 99 counties. While Hubbell carried 11 Iowa counties Tuesday, Democratic congressional candidates won 20 counties across the state.

If Hubbell's performance had mirrored the collective performance of the congressional Democratic candidates (Finkenauer in the 1st District, Dave Loebsack in the 2nd, Cindy Axne in the 3rd and Scholten in the 4th), Reynolds would have lost Tuesday. If every person who cast a ballot in favor of the Democratic congressional candidates had voted for Hubbell, the Democrat would have won by almost 50,000 votes. Instead, Hubbell lost to Reynolds by nearly 40,000 votes.

The 4th District proved exceptional this year, with King facing his toughest opponent yet and fierce criticism from within his own party, said Timothy Hagle, an associate professor of political science at the University of Iowa.

"My guess is that Reynolds did better in the 4th District because there were probably Republicans voting for Reynolds who weren't voting for Steve King," Hagle said. "And that's probably why that race was as close as it was."

While the varied results Tuesday can appear contradictory, Hagle noted that Iowa has long been a swing state. Independents, not Republicans or Democrats, are the largest voting bloc here. They're willing to vote for candidates of both major parties and are less driven by party politics.

"That's the big takeaway, more than anything else," he said. "You’ve got a lot of voters here that are swing voters."

Sioux County

Reynolds put up her best performance in far northwest Iowa's Sioux County, which was also the backdrop to her final campaign appearance Monday evening.

The governor won 86 percent of the vote compared to Hubbell's 13 percent. Her performance in many rural counties like Sioux allowed her to run up vote tallies.

In Sioux County alone, she netted almost 13,000 votes — a significant surplus when compared to her entire statewide margin of victory of about 39,500 votes.

Rural counties are always important for Republicans in Iowa. And Reynolds portrayed herself as a down-to-earth candidate who could relate to people in small towns across the state.

Republican strategist David Kochel, an adviser on the Reynolds campaign, said the governor racked up strong numbers in dozens of counties across the state.

He noted that the governor's margin of raw votes in 63 counties surpassed those earned by Joni Ernst during her 2014 U.S. Senate election.

"Having the strong turnout to match what the Democrats were able to do in some of the urban precincts was crucial," Kochel said. "And she has great appeal really across the state."

Kochel said governor's races are always more focused on local issues than federal elections. He believes Reynolds' record and her relatable background helped her win over voters in all corners of the state.

Reynolds won 88 counties in all.

"Iowa is a lot more than just Polk County," Kochel said. "There’s 99 counties, and a lot of them aren’t as populated. But they sent a pretty strong message last night that they appreciate her background, her story and her ability to reflect all of Iowa."

Polk County

Hubbell put up his best performance in Polk County, home to the state's capital city and largest metropolitan area.

In Polk County, Hubbell won by nearly 18 percentage points, netting more than 35,000 votes. That showing even topped Axne's margin in Polk County, the only county she won in the 3rd Congressional District.

Many of the 11 counties Hubbell won are home to the state's largest cities, including Cedar Rapids, Davenport, Dubuque, Iowa City and Waterloo. But even in many of those urban counties, Democratic strategist Matt Paul said Hubbell failed to run up wide enough margins.

"There was just under-performance in key counties that you can't do at the top of the ticket," Paul said. "You need to do well in those counties and hold your own in the more rural places, and that just didn't happen."

While Polk was a huge win for Hubbell, it also highlighted his failure to spread his wins further across the map.

He did win more counties than Hillary Clinton snagged during her unsuccessful 2016 presidential bid (she won just six Iowa counties that year). But his 11 counties still were far short of previous statewide wins for Democrats.

During his presidential bids, Barack Obama won 53 Iowa counties in 2008 and 38 counties in 2012. Former Gov. Tom Vilsack captured wins in 68 counties during his successful re-election campaign in 2002.

"You shouldn't rely on a path to victory that only includes 11 counties in the state," said Paul, who ran Clinton's Iowa caucus campaign.

Tuesday's results appeared to crystallize Iowa's growing rural-urban divide, said Republican strategist Matt Strawn. He said Iowa Democrats still haven't found a way to make inroads with rural voters.

"The redder areas are getting redder," said Strawn, the former chairman of the Iowa Republican Party. "You’re seeing the bluer urban centers get bluer. And it looks like the suburbs are going to be caught in the middle."