GOTHENBURG, Sweden – Gangs of black-clad men torched cars with assembly-line precision here in Sweden’s second-largest city last month. One man would smash windows with a bat. Another sprinkled gasoline. A third tossed in a match. Within hours, more than 80 vehicles were in flames.

The episode reinforced the notion that this country is struggling to control gang violence, which many Swedes blame on immigrants. It’s a fear that could help the Sweden Democrats, a far-right group with neo-Nazi origins, become one of the largest parties after Sunday’s elections.

Long considered toxic in this traditionally liberal nation, the Sweden Democrats have undergone a repackaging. They’ve traded jackboots for business suits, purged some of their overtly racist elements and adopted more urbane messaging. Immigration, though, remains their overriding focus. Leader Jimmie Akesson once called Sweden’s growing Muslim population “the biggest foreign threat since the Second World War.” In this campaign, he has linked immigration, crime and the decline of the Swedish welfare state.

“It’s enough to look at these images of burning cars. The socioeconomic gap in Sweden hasn’t closed, it has just widened and widened,” Akesson told a rowdy rally last week in Gothenburg.

“Sweden has never been more polarized, more segregated. We have never had such a deep divide. Our country is being torn apart,” he said to cheers.

His party is polling at about 20 percent, up from 13 percent in the last elections in 2014, before Europe’s migration surge. If Sunday’s election results come close to matching the polls, the Sweden Democrats have a shot at becoming the second-largest party in the country. Some analysts believe they could even soar to the top, deposing the ruling center-left Social Democrats from a perch they have held since 1917.

The party is unlikely to formally join a ruling coalition, as far-right forces have done in Italy and Austria, because other parties still consider the Sweden Democrats noxious enough that they don’t want to give them cabinet positions if they can avoid it.

But the support of the Sweden Democrats still could be key during frantic post-election negotiations and afterward, as the new government tries to move legislation.

In the past, there was a feeling that “if the Sweden Democrats adopt one view, then we must adopt a different view,” said Johan Forssell, the spokesman for migration of the center-right Moderates party. Now, he said, his party would be happy to use Sweden Democrats support on issues where their views intersect, including migration and crime.

Already, the far-right has won the contest to determine the national agenda. Rivals have sought to prove that they, too, can be tough on lawbreaking and immigration. They’ve scrambled to match proposals for mass deportations, strict border controls and an end to taking in refugees from the Middle East.

After the arsons in Gothenburg, Prime Minister Stefan Lofven considered sending the military into the heavily immigrant, low-income areas that were hit. Such a move would have been a major departure for the center-left party that helped build Sweden’s social welfare system, in which many lawbreakers serve lighter prison sentences than in other countries on the theory that there are more effective ways to address criminality.

In a sense, Sweden has embraced the same anti-immigrant attitude that has washed across Europe and the United States. President Donald Trump has also blamed immigrants for crime – and once held up Sweden as an example of what to avoid, though the attack he cited never happened.

Yet the shift in sentiment is especially notable in Sweden, because it has been one of the world’s most giving countries to those in need going back to World War II.

At the beginning of Europe’s migration crisis in 2015, Sweden’s arms were wide open. Crowds gathered at train stations in large cities to welcome new arrivals. Swedes helped refugees get access to housing, medical care and other social benefits the country prides itself on.

By the end of that year, Sweden had taken in 163,000 asylum seekers, more than any other European country in comparison to its size. Swedes began to worry that they and Germany were poised to bear Europe’s refugee burden largely alone. Swedish leaders imposed temporary border controls, which they’ve continued to renew.

Even as migration has diminished to pre-crisis levels, Swedish generosity has not rebounded.

“In the beginning, people were very welcoming,” said Zahra Samadi, 23, an Afghan refugee who arrived in Gothenburg in 2011 and has campaigned against the deportations of other Afghan asylum seekers. “In all of Europe, there was a tide that turned in 2015.”

The Sweden Democrats say the rest of Swedish society has finally caught up with them. They point to studies that say people with immigration backgrounds are overrepresented in certain types of Swedish crime statistics, including rape convictions.

“To me, it’s been plain stupid to be afraid of facts,” said Paula Bieler, a Sweden Democrats lawmaker who leads the party’s migration policy. Migration “will affect the number of men who are potentially rapists,” she said.

The official keepers of Sweden’s crime statistics, however, dispute a clear causal link between the 2015 migration wave and crime.

“The Sweden Democrats are very good at picking correct facts from the agenda, so you cannot say an individual fact is wrong. But they do not point out the facts that problematize what they are saying,” said Stina Holmberg, a researcher at the Swedish National Council for Crime Prevention.

For example, Holmberg said, although the number of Swedes who say they faced sexual offenses in the previous year has gone up, that could be related to the #MeToo discussion and broadening definitions of what should be considered an offense. The number of sex crimes reported to the police have actually dropped in recent years.

Criminologists say gang activity is up, much of it concentrated in immigrant-heavy, low-income neighborhoods. And in the most prominent incident involving an immigrant, an asylum seeker from Uzbekistan was convicted of driving a truck into a Stockholm department store and killing five people last year.

Still, most Swedes are freer from crime than they were two decades ago. Violent crime is little changed from two decades ago, averaging 110 murders a year since 2015, compared to an average of 107 incidents per year in the early 1990s when Sweden’s population was 14 percent smaller. The number of arsons is flat, according to statistics from the Swedish Civil Contingencies agency.

But because “crime is so high on the political agenda right now,” incidents such as the car fires can explode “like dynamite,” said Robert Karlsson, the deputy police chief of the western coastal region of Sweden that includes Gothenburg. “This is not a lot of people we’re talking about here. It’s 20 people here, 15 people there, affecting millions of people.”

Mainstream Swedish parties have found it hard to compete with perceptions.

“If you are afraid to go home from the subway, you don’t want a politician saying, ‘Hey, but this is much safer than it was 150 years ago,’ ” said Anders Ygeman, the parliamentary leader of the ruling Social Democrats, who was interior minister during the height of the migration crisis in 2015.

“Maybe a little bit we have been weighing on statistics and not discussing people’s fear,” he said.

Two weeks after the Gothenburg fires, scorched black marks still outlined the burned-out cars on the pavement of a mall parking lot.

“It smelled like rubber, and it felt like a war zone. The tires were burning,” said Zagros Hama, 19, who is running for a seat on the Gothenburg city council as a candidate from the center-right Moderate party and who live-streamed a video of cars in flames.

He blamed Sweden’s integration policies. Hama’s parents immigrated to Sweden from Iran and Iraq 25 years ago, he said – arriving in a very different country. “When they came here, they had to learn Swedish. They had to integrate. Now you don’t have to become Swedish,” he said.

Residents of some heavily immigrant areas push back and say the discussion about crime and migration is simply a thinly veiled way to bring racist ideas into the mainstream.

“I’ve lived here all my life, and I feel a little bit less Swedish because I’m wondering if my heritage is a problem for me,” said Kareem Zuwa, who runs a youth center in Gothenburg and moved with his parents from Tanzania when he was 3.