LOUISVILLE, Ky. (WDRB) -- Democrat Andy Beshear appeared to narrowly unseat Republican Gov. Matt Bevin on Tuesday, capping a bruising and tight race for Kentucky governor.

But Bevin refused to concede in a contest the Associated Press said was too close to call. 

Buoyed by support in Louisville and Lexington, Beshear built a sizable lead that gradually diminished as results trickled in from GOP-leaning counties in western Kentucky. 

Beshear, the state's attorney general, had captured 49.2% of the vote with all precincts reporting Tuesday night, according to AP data. He led Bevin by 5,150 votes, or less than 0.4% of the 1.4 million total ballots cast.

Around 10 p.m., Bevin appeared at the Galt House hotel in downtown Louisville and told supporters there had been "irregularities" connected with the vote.

"This is a close, close race," he said. "We are not conceding this race by any stretch."

Under Kentucky law, candidates can ask for a "recanvass," which requires local election boards to double check each election machine, essentially verifying that ballots were tabulated correctly. Bevin would have to ask for a recanvass by next Tuesday. 

He also could seek an "election contest," a rare maneuver that ultimately could force the Republican-controlled legislature to decide the election.

"We know for a fact that there have been more than a few irregularities. They are very well corroborated and that's all right," Bevin said. "What they are exactly, how many, which ones and what effect, if any, they have will be determined according to law that's well established."

Davis Paine, Bevin's campaign manager, did not respond to voice mail and text messages seeking comment Tuesday night. The governor did not elaborate on his claims. 

In a speech declaring victory, Beshear said he hadn't spoken with the governor, but "my expectation is he will honor the election that was held tonight and he will help us make this transition -- and I tell you what, we will be ready for that first day in office."

A Beshear win would return the governor’s mansion to Democrats for the first time since 2015, when Beshear’s father, Steve Beshear, ended his two terms as the state’s chief executive and Bevin won office over Democratic nominee Jack Conway. 

Bevin appeared to lose on a night when other Republican candidates won easily and not a single Democrat other than Beshear won a race for a constitutional office.

Beshear, 41, campaigned on his four-year record as attorney general, emphasized his legal battles against Bevin and pledged to fight for affordable health care. In a key departure from Bevin, Beshear backed expanded gambling and pledged to use new revenues to help fund pension shortfalls.  

Beshear also ran on a platform backing teachers, who frequently sparred with Bevin over pension funding. His running mate for lieutenant governor, Jacqueline Coleman, is an assistant principal at Nelson County High School.

Beshear’s apparent win comes a day after President Donald J. Trump appeared on stage with Bevin during a rally in Lexington’s Rupp Arena. Bevin had touted his relationship with Trump during the campaign.

"The President just about dragged Gov. Matt Bevin across the finish line, helping him run stronger than expected in what turned into a very close race at the end," Trump campaign manager Brad Parscale said in a press release Tuesday night.

Beshear took more than two-thirds of the vote in Jefferson County, the state's largest. Louisville votes accounted for about 26 percent of his entire tally statewide. 

In all, Beshear garnered 98,772 more votes than Bevin in Jefferson County, where both men live. By comparison, Democrat Jack Conway won the county by 37,805 votes over Bevin in the 2015 race for governor.

Bevin, 52, repeatedly emphasized job growth and economic development in his reelection bid, including figures that show Kentucky has added 57,000 new jobs since he was elected. Among other issues, Bevin also touted his anti-abortion record and his administration’s effort to fund public pensions.

As governor, Bevin’s blunt style and controversial remarks has put him occasionally at odds with his own party.

In 2017, for example, he vetoed a Republican-backed bill to get Kentucky in compliance with federal Real ID standards. A year later, the GOP General Assembly voted to override Bevin’s vetoes of the state budget and a tax bill that would raise $480 million in revenue by expanding the reach of the state sales tax and other measures.

One Republican, retiring state Sen. Dan Seum of Fairdale, endorsed Beshear.

To see real-time updates of all races, click here.

Copyright 2019 WDRB Media. All Rights Reserved.