Kentucky Attorney General Andy Beshear (D) on Tuesday claimed an upset win over Gov. Matt Bevin (R), declaring victory in the race for a critical seat in a state that is rapidly becoming more conservative.

"In Kentucky, we can disagree with each other while still respecting each other," Beshear said during a speech claiming victory on Tuesday night. Beshear said he had not talked to Bevin but told supporters, "My expectation is that he will honor the election that was held tonight."

With 99 percent of precincts reporting, Beshear led Bevin by a 49.2 to 48.8 percent margin. Kentucky Secretary of State Alison Lundergan Grimes (D) called the race shortly before 10 p.m. during an appearance on CNN.

"Here in the commonwealth, we have called it for Attorney General Beshear to be the Kentucky governor-elect for the commonwealth," she said.

Bevin has not conceded in the race, and The Associated Press and several other major outlets said it remained too close to call late Tuesday.

Kentucky does not have a process for automatic recounts, but candidates can request that counties recanvass their results, or they can pursue a vote recount or full legal challenge.

Though Kentucky has more registered Democrats than Republicans, its shift in recent years toward cultural conservatism should have made Bevin the favorite for a second term.

But he spent his first four years in office fighting with interest groups across Kentucky, including teachers who went on strike and then took offense when Bevin insulted them to members of his own party in the state legislature.

He even fought with his own hand-picked lieutenant governor, whom he unceremoniously dropped from the ticket earlier this year.

His approval rating slumped with each successive incident. In an indication that Bevin's political problems did not extend to the rest of the state Republican Party, the GOP won every other statewide race on the ballot Tuesday, including Beshear's soon-to-be-former job as attorney general.

To save himself, Bevin turned to a temperamental twin in the closing weeks of the race: Trump.

Bevin spent the final weeks of the race criticizing Democrats' attempts to impeach Trump, an issue no Kentucky governor has a say in but one that connected Beshear with national Democrats who are deeply unpopular in the Bluegrass State.

Trump, who won Kentucky's electoral votes by almost 30 points and remains broadly popular there, spent the evening before Election Day stumping with Bevin in Louisville. He joked that Bevin is "such a pain in the ass" as he endorsed his ally's reelection bid.

Beshear spent the bulk of his race talking instead about local issues such as teacher pay raises and protecting the Medicaid expansion his father, Bevin's predecessor in the governor's office, signed into law.

The apparent loss is a blow to Republican hopes of building momentum toward 2020, though it does little to indicate a groundswell among voters who plan to reject Trump.

Voters tend to see governor's races through different lenses than they see federal contests, giving Republicans a chance to win seats in states such as Massachusetts, Maryland and Vermont and Democrats the ability to win in states such as Montana and Kansas.

Updated: 11:27 p.m.