LEXINGTON, Ky. — Republican Gov. Matt Bevin had one final lecture for the Kentucky press corps.

He had just come off the stage after another contentious debate with his Democratic challenger and was sparring with reporters at a news conference.

“I know you are voting for the other guy,” Bevin snapped, referring to his opponent, state Attorney General Andy Beshear. “But he’s going to lose because you are not representing the way the people of Kentucky actually feel.”

As Bevin walked away, a local reporter asked, “Governor, do you think you rub people the wrong way?”

“I think it happens on a regular basis,” Bevin responded. “It’s called the truth.”

In the run-up to the Nov. 5 election, Bevin’s “truth” is on the ballot as he fights for reelection with a reputation as one of the nation’s meanest and most unpopular governors. Bevin has criticized and insulted teachers, pushed through a controversial “right to work” law, and publicly battled his own lieutenant governor and state lawmakers. One Republican recently held a “bullied by Bevin” picnic and endorsed the governor’s Democratic opponent.

The 52-year-old governor, however, is embracing his abrasive political style and aligning with another hard-edge politician, President Trump, in hopes of becoming the first Republican Kentucky governor to win a second term.

As Republican voters here struggle to decide whether their partisan loyalty outweighs their doubts about Bevin’s personality, the Kentucky election mirrors the nationwide challenge that Trump could face next year to win over voters who may agree with his policies but are turned off by his tweets, controversial statements and Oval Office antics.

“If you look at this race on paper, [Bevin] ought to be 15 points ahead. But it’s his personality, that is what’s holding him back,” said Al Cross, a veteran political columnist who teaches journalism at the University of Kentucky. Cross added, “Kentuckians like a tough governor. I don’t think they want a mean governor, and he sounds mean a little too often.”

Chuck Adams, a registered Republican from the exurbs of Cincinnati in northern Kentucky, voted for Bevin four years ago but is unsure if he will vote for him again.

“I like the way he’s governed the state; he’s not apologetic, but he’s a little bit too abrasive,” said Adams, 71, who owns a fast-food restaurant. “It’s just like I feel about Donald Trump. Sometimes I just want to say, ‘Quit knocking people like you do.’ ”

Kentucky has been trending Republican in national elections for decades, but about half of its voters are still registered as Democrats. Bevin is only the state’s second Republican governor in 50 years, but Republicans hold the majority in the Kentucky legislature and five of the state’s six congressional seats.

President Trump won the state by about 30 points in 2016.

Bevin was elected in 2015 after he campaigned as a businessman and an outsider who vowed to cut taxes and spending. In office, Bevin’s efforts to balance the state budget and reform the state’s pension system quickly escalated into a political brawl with Kentucky teachers.

Repulsed by the GOP proposal to cut pension benefits while increasing teachers’ payments to the fund, Kentucky teachers staged a walkout and sickout that shuttered schools for several days. Bevin accused the teachers of being thuggish ” and “selfish” while acting like “misbehaving children,” according to local news reports.

Bevin’s popularity has also been hobbled by clashes with labor unions and his own lieutenant governor, whom he dropped from his ticket earlier this year.

Bevin has denied characterizations that he has been mean to teachers, accusing the news media and teachers of taking his comments out of context.

Beshear, the son of a former Kentucky governor who is in his first term as attorney general, is seeking to capitalize on Bevin’s drama by portraying himself as a stable, collaborative leader. Beshear had been a vocal opponent of the pension bill, winning a Kentucky Supreme Court ruling that blocked the GOP legislation.

Beshear wants to legalize gambling and medical marijuana and use the tax revenue to shore up the state pension system.

“I want to bring us together, enough of this us-versus-them,” Beshear, 41, said during a recent debate.

Kentucky teachers are forming the backbone of Beshear’s campaign, pouring more than $2 million into the race.

With local school systems forming the largest employers in many rural counties, Democratic strategists say their biggest asset is the one-on-one discussions delivering an anti-Bevin message that teachers are having with voters.

“Kentuckians take it very personally when other Kentuckians are picked on,” said Nema Brewer, a school system employee and leader of 120 Strong, a grass-roots worker advocacy group. “Matt Bevin has insulted working people, continually, and it’s a lot different when it’s your next-door neighbor.”

Outside the debate in Lexington, teacher Kyla Trahan walked up and down the sidewalk carrying a large sign referring to Bevin as a “bully.” Trahan, a 39-year-old Republican with two master’s degrees, said Kentucky teachers are taking their message directly to voters, pointing out the sacrifices they’ve made for students in one of the poorest states in the nation.

“I give money to my students, buy them clothing, and we’ve even bought beds for our kids,” said Trahan, who teaches in Fayette County and earns about $60,000 a year. “How am I a thug when I am spending my personal income on my students?”

Bevin is fighting back by citing the state’s economic successes, including an unemployment rate that has been hovering around 4 percent, a two-decade low. He has also linked himself to Trump, both stylistically and politically.

When he campaigned at the Kentucky State Fair in August, Bevin wore a blue and white jacket covered in images of Trump’s face. He emulates Trump’s scorching debate style, lobbing allegations of “corruption” or “fraud” at Beshear. Bevin has noted that a former top aide to Beshear, who also had worked for his father’s gubernatorial administration, was sentenced to 70 months in prison in 2016 after he admitted to accepting kickbacks for state contracts. Beshear was not accused of wrongdoing.

In one television ad, Bevin links himself to Trump on illegal immigration, using images of heavily tattooed men and grainy video of people jumping a fence while the narrator states, “Andy Beshear would allow illegal immigrants to swarm our state. . . . While President Trump and Governor Bevin crack down on illegal immigration, liberal Andy Beshear sides with illegal immigrants.”

Trump has tweeted support for Bevin and plans to hold a rally in Lexington the day before the election.

Tres Watson, a Republican strategist, said Bevin’s campaign is built around convincing Republican-leaning voters that they should stick with their party, even if they have disagreed with some of the governor’s approaches to handling his standoff with the teachers and other political opponents.

“The question is how mad are they at Matt Bevin and what is their threshold of anger versus issues and partisanship?” Watson said. “When Trump comes here and says, ‘Vote for Matt Bevin,’ I think a lot of people will say, ‘I hate this guy, but I will still vote for Matt Bevin.’ ”

There are signs that Bevin’s strategy is working. Although public and private polls earlier this year showed Beshear comfortably ahead, a survey released this week by Mason-Dixon Polling & Strategy signaled the two candidates were tied, with each getting 46 percent of the vote. Bevin’s support among Republicans had jumped 10 percent since December, the poll noted.

Bevin still faces hurdles. In the Cincinnati suburbs, where Democrats are hoping to make inroads, Republican Betty Sanders said she is a strong Trump supporter but has already decided she won’t vote for Bevin because “there is no excuse for betraying a teacher.”

“It was the most outrageous, ridiculous thing I’ve seen a human being do to other human beings,” said Sanders, 69, a retired nurse who added she wouldn’t vote for Bevin even if Trump personally asked her to do so. “I would tell President Trump to his face, ‘Why are you even supporting this jerk?’ ”

Still, in a state where “choose life” signs are displayed in many front yards, Bevin maintains solid support from religious conservatives. Earlier this year, he signed several bills restricting access to abortion, and he frequently notes that the state has just one clinic.

David Larsen, 49, said Bevin’s opposition to abortion is all he needed to hear to overcome his misgivings.

“I will vote for him because he’s pro-life and that to me right there is the big issue,” said Larsen, who works at a local warehouse.

In suburban Lexington, other Republican voters said they expect even more GOP partisans to rally around Bevin because, in part, they feel like he’s been unfairly treated by the media and his political opponents. They compare it to their belief that Trump also isn’t being given a fair shake.

“I think people aren’t seeing his accomplishments and seeing the challenges he’s taken on that no other governor has taken on,” said Gail Whitt, 65, a state worker who credits Bevin with trying to save the pension system. “I know he, like Trump, needs to keep his mouth shut a little bit, but that is just where we are with our politics.”

This story has been updated.