NEW YORK — Weeks before the statue of Robert E. Lee in Charlottesville, Virginia, became a flashpoint in the nation’s struggle over race, it was the focus of emotional debate in the state’s Republican primary election.

Corey Stewart, an outsider candidate for governor sometimes compared to President Donald Trump, seized on possible removal of the Confederate general’s memorial as an “attempt to destroy traditional America.” Stewart, who said in an interview Tuesday that such an action “hits people in the gut,” found unexpectedly strong support, forced his main opponent to defend the statue and almost won.

Now the fight over “traditional America” is throwing a spotlight on the Republican Party’s struggle with race in the age of Trump. The deadly white supremacist rally against removal of the Lee statue served as a painful example of the uncomfortable alignment between some in the party’s base and the far-right fringe. But despite the party’s talk of inclusiveness and minority outreach, it’s clear white fears continue to resonate with many in the GOP base. Politicians willing to exploit those issues are often rewarded with support. One big beneficiary, critics say, has been the president himself.

WATCH: Trump blames ‘both sides’ for violence at Charlottesville rally

For those critics, on both the left and right, Trump’s response to Charlottesville was a glaring example. On Saturday, he denounced hatred and violence on “many sides,” seeming to assign blame equally to counter-protesters as well as hate groups protesting the proposed removal of the statue. He waited until Monday to specifically name the groups he was condemning — the KKK, neo-Nazis and white supremacists.

For Republicans who hoped the president might use the moment to send a new message about racism and their party, Trump failed the test.

“We have reached a defining moment,” said New Hampshire GOP chair Jennifer Horn. “We, as Republicans, every single one of us, needs to speak up and make it very clear that this is not our party, these are not our values.”

“We have reached a defining moment,” said New Hampshire GOP chair Jennifer Horn. “We, as Republicans, every single one of us, needs to speak up and make it very clear that this is not our party, these are not our values.”

Such moments have the potential to undermine years of attempts to portray the party as more welcoming to minority voters.

The Republican National Committee, led by Trump’s former chief of staff Reince Priebus, released an exhaustive report in 2013 noting that the GOP’s traditional base of older, white voters was becoming a smaller and smaller portion of the electorate in America. “If we want ethnic minority voters to support Republicans, we have to engage them and show our sincerity,” the RNC wrote.

Yet Republican officeholders, including the president, have found success by seizing on semi-hidden “dog whistle” rhetoric and policies largely designed to appeal to whites.

Across the Midwest, Trump and others have appealed to suburban white voters by decrying a rise in urban violence, even as statistics show violent crime is down in many cities.

With no evidence of widespread voter fraud, Republicans nationwide have promoted voter ID laws that several courts determined discriminate against minority voters.

Trump’s promise to build a massive wall along the southern border resonates with conservatives across the West and even in overwhelmingly white Northeastern states where Republicans fear the influx of illegal Hispanic immigrants.

And, particularly in the South, some conservatives continue fight to preserve symbols of a Confederate Army that fought for Southern states’ rights to continue slavery. The relics are simultaneously denounced as symbols of oppression by most blacks and celebrated as marks of Southern pride by many whites.

This week in Alabama, three Republicans running in Tuesday’s special U.S. Senate primary demonstrated the careful tiptoeing politicians do around the subject.

Rep. Mo Brooks generally bemoaned “bigotry.” Former Alabama Supreme Court Justice Roy Moore rejected “violence and hatred.” Sen. Luther Strange, appointed to the seat when Trump tapped Jeff Sessions as attorney general, made no reference to racial motivations at all.

Brooks and Strange also expressed support for Trump’s remarks, and Strange seemed to echo the president’s assertion that “many sides” were at fault, as he encouraged “Americans to stand together in opposition to those who encourage hate or promote violence.” Trump recently endorsed Strange.

READ MORE: What to watch in Alabama’s special election

The careful language reflects a political reality in a state where nearly all Republican votes come from white voters, says David Mowery, an Alabama-based political consultant who has worked for Republicans and Democrats. That doesn’t mean Republicans actively pursue racist votes, he said, but sometimes it means they take the most cautious path to avoid controversy.

“I don’t think here that any Republican benefits by talking about it or is necessarily hurt by not talking about it,” he said.

Former South Carolina Gov. Nikki Haley, now Trump’s representative to the United Nations, said as recently as 2014 that the Confederate battle flag should fly at the state Capitol. She changed course two summers ago only after a white supremacist who was photographed holding a Confederate flag murdered nine black people inside a South Carolina church. About the same time, then-Gov. Robert Bentley of Alabama removed Confederate banners from a Confederate monument outside his office, though the monument remains.

In this year’s Virginia primary for the Republicans’ candidate for governor, outsider Stewart lost to establishment favorite Ed Gillespie, but by less than 2 percentage points. On Sunday, Gillespie attended church in Charlottesville and minced no words in naming names and urging those responsible for the violence to take their “vile hatred” out of the state.

“We have stared down racism and Nazism and white supremacy before, and we will stare it down again,” the Republican candidate for governor told a local TV station.

His campaign later added that Gillespie continues to oppose removal of confederate statues, but “believes it is an issue best resolved at the local level.”

Stewart is now running for the Senate in 2018.

AP writer Alan Suderman in Richmond, Virginia contributed to this report.