President Trump and his Republican allies, having tried to stoke public fears of Central American migrants ahead of the midterm elections, are suddenly facing accusations that they helped foment a rising right-wing extremism that poses a far greater national security threat.

Over the past few days, the killings of two African Americans in a grocery store outside Louisville, a series of mail bombs targeting a dozen high-profile Democrats allegedly sent by a Trump supporter, and a mass shooting at a Pittsburgh synagogue have left the nation on edge.

The common thread among them appears to be the targeting of specific groups based on race, religion or political persuasion.

Trump has denounced the attacks and called for national unity. At a campaign rally in Illinois Saturday night, Trump said that “the scourge of anti-Semitism cannot be ignored, cannot be tolerated and cannot be allowed to continue.”

But his critics countered on Saturday that the president and the GOP, in a cynical pursuit of political power, have gone beyond partisan political combat into outright demagoguery against racial minorities, foreigners and prominent Jewish political figures.

Jewish Democratic donor George Soros, for instance, has become a major focus of Republican attack ads ahead of the midterms, even after a bomb was found in his mailbox last week. Trump has accused Soros, without evidence, of paying for protesters at his rallies.

Such rhetoric and actions have provided tacit approval to fringe elements who are considering violence, Trump’s critics said.

“The numerous statements he’s made, calling himself a ‘nationalist,’ crowds at his rallies chanting threats against George Soros — it’s all connected,” said Cecilia Wang, deputy director of the American Civil Liberties Union.

White House aides have rejected such accusations. Trump said the mail-bombing suspect — ­Cesar Sayoc, 56, of Florida — should be prosecuted and punished to the fullest extent of the law, and he called the mass shooting that left at least 11 dead in Pittsburgh a “wicked act of mass murder” by a man who police said made anti-Semitic statements.

The alleged synagogue gunman, Robert D. Bowers, is suspected of blanketing the Gab social media site with anti-Semitic postings.

One post links the Central American caravan – which Trump has used to bolster fears of a wave of unlawful migrants – to the Hebrew Immigrant Aid Society, which helps resettle refugees in American communities.

“HIAS likes to bring invaders in that kill our people. I can’t sit by and watch my people get slaughtered. Screw your optics, I’m going in,” Bowers is suspected of writing hours before authorities said he opened fire at Tree of Life.

Since early in his 2016 campaign, when he denounced immigrants from Mexico as criminals and rapists, Trump has employed language that appeals to the nativist impulses of the electorate — to the point that he was endorsed by former Ku Klux Klan leader David Duke.

In his closing ad during his presidential run, Trump warned darkly of a triumvirate of prominent Jews — Soros, Goldman Sachs CEO Lloyd Blankfein and Fed Chair Janet L. Yellen — and suggested his opponent, Democrat Hillary Clinton, was partnering with them in bad faith in a bid to control the global power structure.

Last year, Trump drew far-reaching condemnation for suggesting, in the aftermath of a white-supremacist rally in Charlottesville during which a counterprotester was killed, that there were “good people on both sides.”

This past summer, Trump repeated, in a tweet, a white-nationalist conspiracy theory, which he appeared to have heard on Fox News, that white farmers were facing mass killings in South Africa. Chants of “lock her up” about Clinton and other prominent Democrats and “build the wall” to keep out immigrants have been a staple of his campaign rallies for years.

In recent days, Trump has taken action against the caravan of Central American migrant families who are traveling by foot in Mexico hundreds of miles from the U.S. southern border. The Trump administration authorized sending 1,000 troops to assist in border security operations, and the White House is weighing a plan to issue a blanket denial for asylum protections, based on national security concerns.

The president has suggested, without offering evidence, that criminals and Middle Eastern terrorists are among the migrants. He and other Republicans, including Rep. Matt Gaetz (Fla.), floated a conspiracy theory that Soros helped fund the caravan.

House Majority Leader Kevin McCarthy (R-Calif.) issued a tweet on Tuesday warning Republicans that they are under threat of losing in November because of financial support for Democrats from Soros, environmentalist Tom Steyer and New York businessman Michael Bloomberg, a former Republican who is now supporting Democrats.

“We cannot allow Soros, Steyer and Bloomberg to BUY the election!” McCarthy wrote. “Get out and vote Republican November 6th! #MAGA.” He deleted the tweet the following morning after authorities said Soros had been targeted in the mail bomb plot.

A spokesman said on Wednesday that the tweet was aimed at highlighting the enormous financial influence of the men and did not condone violence. McCarthy’s office declined to comment further on Saturday.

“For the Republican Party to deny their stoking of these kinds of sentiments is not believable,” said Simon Rosenberg, the founder of NDN, a liberal think tank. Pointing to studies that have shown a rise of white-supremacist-related deadly attacks in the United States, Rosenberg added: “We know that in the United States and Europe right now, there is a rise in right-wing nationalism, and political parties are seeing the fuel of their rise be the fear of immigrants and people not like them — classic xenophobia. Trump is mimicking all of the same.”

McCarthy, who is in line to potentially replace House Speaker Paul D. Ryan (R-Wis.) if Republicans maintain control after the midterms, denounced the “heinous” attack on Tree of Life synagogue Saturday. He pledged to “keep fighting for a country where every religious believer can sit in safety under his own vine and fig tree.”

Ryan called the attacks anti-Semitic, an ideology he said must be eradicated, and he said the nation “will not tolerate this bigotry.”

Yet Ryan’s own Super PAC has been accused of airing campaign ads that have targeted Democrats in racially coded language, including one spot that shows doctored images of an African American candidate in Upstate New York rapping. Ryan’s aides declined to comment for this story.

“The president and leaders in Congress have an opportunity to change the conversation and save lives. They could expel from their base those who seek to win elections by fomenting outrage and fear with racist attacks on immigrants, or anti-Semitic ‘globalist’ conspiracy theories,” said Sen. Chris Murphy (D-Conn.), a prominent gun-control advocate. “They could demand their supporters cool down the rhetoric and stop demonizing and dehumanizing journalists or political opponents.”

Trump has shown no inclination of toning down the rhetoric. At rallies in the past few days, he has aimed his ire on the media, accusing reporters of unfair coverage and “negative attacks that only serve to drive people apart and to undermine healthy debate.”

Responding to reporters Friday, he said that, if anything, he should “tone it up,” and he chose not to cancel a campaign rally in Illinois on Saturday despite the unfolding tragedy in Pittsburgh. Trump said he considered canceling the rally but then “remembered” that the New York Stock Exchange opened the day after 9/11. (That is false. The stock exchange remained closed for six days after the terrorist attacks.)

Speaking to reporters earlier Saturday, Trump professed a level of surprise that something like the Pittsburgh shooting would happen in 2018. “You wouldn’t think this would be possible in this day and age, but we just don’t seem to learn from the past,” he said.

During a rally in Charlotte on Friday, Trump devoted portions of his remarks to fanning fears over the migrant caravan and illegal immigration, warning without evidence that “the Democrat Party is openly encouraging millions of illegal aliens to break our laws, violate our borders, and bankrupt our country. . . . Democrats’ extreme immigration policies will overwhelm your schools, your hospitals, and communities, and strain public resources to the breaking point.”

He also took delight as he appeared to allude to plans to issue an emergency executive order to deny asylum to the migrants.

“Watch next week what’s going to happen — just wait,” Trump said, drawing applause. “It’ll be exciting. It’s going to be great.”

“This is the central premise of his presidency — to attack and smear immigrants and refugees,” Wang said. “All the violence we see is the extreme and radical version of what he is implementing on a policy and legal front as president of the United States.”

Republican commentator Charlie Sykes, a regular Trump critic, suggested on Saturday that the president’s focus is misguided. “So, America,” he tweeted, “perhaps the greatest danger we face is not a caravan 1000 miles away. Maybe it’s already here.”

Paul Kane contributed to this report.