Gov. Scott Walker lost Wisconsin's gubernatorial race to the Democrat Tony Evers in Tuesday's midterm elections.

Evers narrowly led Walker, 49.6% to 48.4%, a margin of 1.2 percentage points, as of Wednesday morning, with nearly all precincts reporting.

After the 2016 presidential election, Walker signed a law that recounts would be allowed only when candidates are projected to be within 1 percentage point of each other.

Scott Walker, Wisconsin's Republican governor, was ousted from office in the state's closest gubernatorial race in more than 50 years in Tuesday's midterm elections, and he won't be able to ask for a recount because of a law he put in place.

With 99% of precincts reporting on Wednesday morning, the Democrat Tony Evers narrowly led Walker, 49.6% to 48.4%, according to The Associated Press. The gap was 1.2 percentage points, or about 31,000 votes out of the more than 2.6 million cast in the election.

After President Donald Trump won Wisconsin by just 23,000 votes in 2016, Walker signed into law a measure mandating that recounts would be allowed only when candidates are projected to be within 1 percentage point of each other.

The law triggers a free recount if the margin is 0.25 percentage points or less. When it's between 0.25 and 1 points, the candidate projected to lose must petition and pay for a recount.

Read more: Midterm key takeaways: Trump's message flops, and Democrats set the stage for 2020

Brian Reisinger, Walker's campaign spokesman, told the AP that Walker wanted an examination of what he alleged were damaged ballots. He also wants to see the official canvas of the vote, which would show him Election Day results as well as results from absentee and accepted provisional ballots.

Evers declared victory at about 1:30 a.m. on Wednesday with almost all precincts reporting, according to the Wisconsin State Journal.

Evers' win also means his running mate, Mandela Barnes, will become Wisconsin's first black lieutenant governor.

Moments before the race was called, Walker's lieutenant governor, Rebecca Kleefisch, said she was prepared for a "long, drawn-out recount" but would "be gracious no matter the outcome," according to the AP.

The loss means Walker will miss out on a third term as governor despite three years ago being seen at one time as a front-runner in the 2016 presidential campaign.

Walker released a statement on Wednesday announcing he would concede to Evers.

"It has been my honor to serve as your Governor for nearly eight years. We've come a long way together and it is my sincere hope that the progress we've made during our time in office will continue and that we can keep Wisconsin working for generations to come," he said.