Republican Mike Dunleavy was set to become the next governor of red-state Alaska on Tuesday night, building a wide lead over Democrat Mark Begich with most precincts reporting.

The former state senator from Wasilla had about 52 percent of the vote with 98 percent of precincts reporting early Wednesday. Begich, a former U.S. senator, had about 44 percent of the vote. Gov. Bill Walker, who suspended his re-election campaign and threw his support to Begich, had 2 percent of the vote.

Dunleavy's win would mean the Alaska Republican Party taking back the governorship after four years of Walker, an independent, in office.

At a Republican watch party at the Anchorage Alehouse on Tuesday, Dunleavy thanked the packed crowd around 11 p.m. He had walked into the restaurant earlier that night to cheers and people chanting his name.

"I'm feeling good about where we're at and I'm feeling really good about where we're going to go with the state of Alaska, so I want to thank everybody for all of your support, being here tonight and throughout this campaign," he told the crowd. "We'll keep watching the numbers but it looks good right now."

In an interview, Dunleavy described his campaign as one of the greatest experiences of his life.

The Dunleavy campaign released a statement around midnight Wednesday saying the candidate had won, referring to him as "governor-elect." Begich and his campaign manager didn't return calls just before 1 a.m. Wednesday.

From the beginning, this campaign has been about the people of Alaska. I am deeply humbled by the trust Alaska’s voters have placed in me, and take seriously the difficult task before us https://t.co/VBg8X1ozMR #akgov #akelect pic.twitter.com/Ua2eTmA0Jd — Mike Dunleavy (@MikeDunleavyGov) November 7, 2018

Dunleavy, 57, and Begich, 56, have been locked in a two-way fight since Walker suspended his campaign for re-election Oct. 19. Just days before that, his former Lt. Gov. Byron Mallott unexpectedly resigned after making unspecified "inappropriate comments" to a woman.

Walker dropping out turned a crowded three-way race into a clearer Republican-versus-Democrat battle for the state's top elected office. But because Walker didn't formally withdraw from the race by the Sept. 4 deadline, his name and Mallott's remained on the ballot.

Walker is the only independent governor in the country, meaning Republicans nationally would count a Dunleavy victory as a win to flip a governorship red in the midterm elections.

Dunleavy said in an interview that the election results show his message resonated with voters.

"I think it's the message that we can develop our resources, that we don't have to default to taxes or Permanent Fund until we get our fiscal house in order. That we need to create jobs," he said.

"I'm not going to celebrate, for example, the expansion of welfare programs," he said. "I'm going to celebrate the expansion of job creation in the state of Alaska, developing our resources in the state of Alaska. I think that's what Alaskans want."

Dunleavy said he planned to go back to Wasilla with his family early Wednesday morning.

"We're going to try to have a night where we're able to fall asleep and not answer the phone for a couple hours," he said.

The Republican candidate running for lieutenant governor alongside Dunleavy is state Sen. Kevin Meyer. Begich's running mate is Debra Call.

Begich walked into Flattop Pizza + Pool in downtown Anchorage on Tuesday night with his family and Call. A crowd of supporters there cheered and chanted, "Mark."

In an interview around 9:45 p.m., Begich said that he anticipated a close race.

"I've been looking forward to this day. This is the day you wait for," he said. "You wait for these numbers and then you — one of two things will happen: You win or you lose. And at the end of the day, we put a great agenda forward."

This year's governor's race came at the tail end of a deep economic recession in Alaska, driven by a crash in oil prices. Lawmakers drained billions of dollars from the state's savings account to fill the resulting budget gaps. Walker also reduced Alaskans' Permanent Fund dividend checks in 2016 in response to the state's fiscal crisis. Lawmakers capped the oil-wealth payouts the following two years.

Both Dunleavy and Begich attempted to tap into the resentment some Alaskans felt after three years of reduced dividend checks.

The PFD and the economy, as well as crime, arose as key campaign topics for both candidates.

Dunleavy and Begich both campaigned on reducing crime in Alaska, but diverged sharply on their plans for the budget and the PFD.

Dunleavy promised full PFDs under the formula in law. He wants to cut the state budget and limit spending. Begich has said Alaska needs revenues, and he'd support certain new taxes. He wants to calculate dividends using a different formula, and use a portion of the money drawn from the Permanent Fund each year to pay for public education.

Libertarian candidate Billy Toien was also on the ballot in the governor's race. He had less than 2 percent of the vote with 98 percent of precincts reporting.

Around 8 p.m. Tuesday, as people trickled into Election Central at the Egan Center in downtown Anchorage, Toien sat at a table with several people holding signs bearing his name.

"It's been long and kind of grueling and this is the grand finale," he said, "and I'm just going to sit back and enjoy the show and watch for the outcome."

Of Alaska's 573,798 registered voters, about 57 percent are nonpartisan or undeclared, about 25 percent are Republicans and about 13 percent are Democrats.

Before Walker, the last three governors in Alaska were Republican. Walker, too, had been a Republican, but switched to independent for his gubernatorial bid in 2014.

Dunleavy was first elected to the state Senate in 2012. He resigned from the senate in January to focus on his campaign for governor. Dunleavy also worked as a school teacher, principal and superintendent in Alaska. He served on the school board of the Matanuska-Susitna Borough School District. Born in Pennsylvania, Dunleavy moved to Alaska in 1983.

This year's governor's race was also marked by big spending by independent expenditure groups. The groups dumped more money into the race in the final weeks leading up to Election Day, trying to win voters over by pushing out a flurry of advertisements and signs. Those groups aren't allowed to coordinate with campaigns, but they are able to raise unlimited money from individuals and organizations.