The thousands of Muslim asylum seekers pouring into Denmark have spawned a backlash, and questions over whether the country has a latent racial hostility at its core.

Denmark — Johnny Christensen, a stout and silver­whiskered retired bank employee, always thought of himself as sympathetic to people fleeing war and welcoming to immigrants. But after more than 36,000 mostly Muslim asylum seekers poured into Denmark over the past two years, Mr. Christensen, 65, said, “I’ve become a racist.”

He believes these new migrants are draining Denmark’s cherished socialwelfare system but failing to adapt to its customs. “Just kick them out,” he said, unleashing a mighty kick at an imaginary target on a suburban sidewalk. “These Muslims want to keep their own culture, but we have our own rules here and everyone must follow them.”

Denmark, a small and orderly nation with a progressive self­image, is built on a social covenant: In return for some of the world’s highest wages and benefits, people are expected to work hard and pay into the system. Newcomers must quickly learn Danish — and adapt to norms like keeping tidy gardens and riding bicycles.

The country had little experience with immigrants until 1967, when the first “guest workers” were invited from Turkey, Pakistan and what was then Yugoslavia. Its 5.7 million people remain overwhelmingly native born, though the percentage has dropped to 88 today from 97 in 1980.

Bo Lidegaard, a prominent historian, said many Danes feel strongly that “we are a multiethnic society today, and we have to realize it — but we are not and should never become a multicultural society.”

The recent influx pales next to the one million migrants absorbed into Germany or the 163,000 into Sweden last year, but the pace shocked this stable, homogeneous country. The center­right government has backed harsh measures targeting migrants, hate speech has spiked, and the anti­immigrant Danish People’s Party is now the second largest in Parliament.

Some of the same hostilities were reflected this weekend in Germany, where voters in Chancellor Angela Merkel’s home state embraced anti­immigrant candidates — an emphatic rejection of her refugee policy.

There is new tension between Danes still opening their arms and a resurgent right wing that seeks to ban all Muslims and shut Denmark off from Europe. Mr. Christensen, the retired banker, supports emerging proposals for his country to follow Britain in exiting the European Union.

There is tension, too, over whether the backlash is really about a strain on Denmark’s generous public benefits or a rising terrorist threat — or whether a longstanding but latent racial hostility is being unearthed.

Analysts say that the public voiced little opposition after 5,000 Poles and 3,300 Americans, among other Westerners, emigrated to Denmark in 2014, but that there has been significant criticism of the nearly 16,000 Syrian asylum seekers who arrived that year and the next. They and other migrants were not invited, and many ended up here by accident, intercepted on their route to Sweden.

Critics complain that these newcomers have been slow to learn Danish — though the immigration ministry recently reported that 72 percent passed a required language exam. Some Danes blister at what they see as ethnic enclaves: About 30 percent of new immigrants lived in the nation’s two largest cities, Aarhus and Copenhagen, where Muslim women in abayas and men in prayer caps stand out among the blond and blue­eyed crowds on narrow streets.

Perhaps the leading — and most substantive — concern is that the migrants are an economic drain. In 2014, 48 percent of immigrants from non­Western countries ages 16 to 64 were employed, compared with 74 percent of native Danes.

The immigration ministry has sought to avoid what it calls “parallel societies” of migrants living in “vicious circles of bad image, social problems and a high rate of unemployment.” Tightened immigration requirements, the ministry said in its latest annual report, weed out those “who have weaker capabilities for being able to integrate into Danish society.”

Omar Mahmoud, 34, an Iraqi engineer who entered Denmark a year ago and lives in a refugee center in Randers, a city of 60,000, is trying his best to fit in. He and his wife are taking Danish classes, and their three children are learning the language and making Danish friends in school. They are Muslim, but attend church to learn about Christianity, and he said he was not opposed to his son’s eating pork, a staple of the Danish diet, though it is forbidden in Islam.

Mr. Mahmoud said his family had not encountered direct insults or threats, but was frightened by the anti­immigrant and anti­Muslim tenor in the public discourse.

“It’s like foreigners are put in a special clan, separate from the Danish people,” he lamented. Still, Mr. Mahmoud said that “some of the Danish people are angels” and that he was relieved to be far from the violence of Iraq. “I’m in my heaven now.”

Anders Buhl­Christensen, a center­right city councilman in Randers, said the influx had forced a more honest conversation about national identity. “Our problem in Denmark is that we’ve been too polite,” he said. “No one dared talk about” immigration, he added, “because they were afraid they’d be called racist.”

‘It’s not racism to be aware of the difference’

Denmark is just one of many European nations grappling with the wave of migrants amid a spate of terrorist attacks across the Continent by Islamic extremists: A recent Pew Research Center survey found that at least half the citizens in eight of 10 countries polled said incoming refugees increased the likelihood of terrorist attacks.

The confluence of these and other factors has prompted a re­examination of the postwar promise of a unified, borderless Europe. Macedonia, Hungary and Slovenia have all built border fences. Denmark imposed new identity controls on its border with Germany in January, and for the first time since 1958, Sweden requires entering Danes to show identity papers.

Many analysts saw Britain’s surprise vote to leave the European Union as an angry expression of concern that British — or, especially, English — identity was being diluted by the nation’s growing diversity. Debate is raging anew over whether certain Islamic modes of dress — full­body swimsuits, known as burkinis, in France and face veils in Germany — inherently contravene countries’ values.

Similar themes are seen as underpinning a wave of new measures here in Denmark.

The government has made its citizenship test more difficult and slashed by nearly half a package of integration benefits. A measure passed in January, though rarely enforced, empowers the authorities to confiscate valuables from new arrivals to offset the cost of settling them.

Last year, Denmark placed ads in Arabic­language newspapers stressing its tough new policies, essentially suggesting: Don’t come here.

Muslims do not assimilate as easily as Europeans or some Asians, said Denmark’s culture minister, Bertel Haarder, partly because, as he put it, their patriarchal culture frowns on women working outside the home and often constrains freedom of speech.

“It’s not racism to be aware of the difference — it’s stupid not to be aware,” Mr. Haarder said. “We do them a blessing by being very clear and outspoken as to what kind of country they have come to, what are our basic values.”

But much of the difference remains unspoken. This is a country where pedestrians wait for a green light to cross even when no cars are in sight, a contrast to the bustling streets of Middle Eastern capitals.

Birgitte Romme Larsen, a Danish anthropologist who has studied refugees and asylum seekers in rural areas, mentioned an African refugee who did not realize that closing his curtains during the day was interpreted as being unduly secretive. Other newcomers were not aware that congregating and talking loudly at a grocery might offend Danish sensibilities.

“These implicit expectations cannot be written into an integration folder” migrants receive, Ms. Larsen said.

‘A Dane of a different color’

Sherif Sulaiman, an organic food scientist who moved to Denmark eight years ago from Egypt, said Muslims must not close themselves off in enclaves but open themselves up for interaction.

He is the manager of an Islamic center that opened in 2014 and invites Danes in for meals and for an annual “harmony week.” Mr. Sulaiman pushed to have the mosque complex use Scandinavian architectural style and furniture, and lends its conference room to a church for meetings.

“We should be like this glass — transparent,” he said, pointing to a window. “As long as we follow the rules of the country, we are part of Danish society.”

But some dark­skinned immigrants who have lived in Denmark for decades say assimilation seems an elusive and ever­shifting target.

Patricia Bandak and her brother Sylvester Bbaale came to Denmark from Uganda as babies in 1989. Like their native neighbors, they are polite and punctual and ride their bicycles everywhere.

The siblings are not Muslim but said they frequently encountered racism: In school, they were called the N word, and told that they should stop eating Ugandan food like matoke, a starchy fruit. Mr. Bbaale, who is 27 and operates a food truck, said he was beaten on the street last year by three men who cursed at him and told him to go back to Africa.

“For a lot of people, being Danish is in your blood, so I will never be Danish,” said Ms. Bandak, 28, who became a Danish citizen in 2010 and is studying documentary film. “I call myself a Dane of a different color.

” Then there is Ozlem Cekic, a Turkish­born Muslim who served as a leftist member of Parliament from 2007 to 2015. Her three children were born in Denmark, she wrote a 2009 memoir in Danish, and, she said, “I even dream in Danish.”

Yet Mrs. Cekic, 40, said she often received death threats and heard shouts of “Go home!” on the street. Every time terrorists strike Europe, she is bombarded by hundreds of hate messages. Lately, people have inundated her with accusations that Muslims are milking the welfare system and plotting against Danes.

While in Parliament, Mrs. Cekic held “dialogue coffees,” where she would explain — in fluent Danish — why she is as Danish as anyone.

“They meet me for coffee and suddenly they say their problem isn’t with me but with those other people,” she recalled. “I tell them: I am the other.”

‘Denmark is closing in on itself’

Karin Andersen is one of thousands of Danes trying to help the immigrants settle through groups formed on Facebook called Venligboerne, or Kind Citizens. She spends several days each month with Housam Mohammed Shamden, 38, his wife and two daughters, who fled Syria in 2014 and now live in Randers, with small Danish flags taped to the front door of their apartment and tucked into flower vases.

“Danes are so concerned about losing their culture,” said Ms. Andersen, 62, a retired teacher. “But how many help the ones who want to be part of it?”

However many, they are often drowned out by reports of Muslims being spat at and showered with racist slurs. In May, two Danes ripped the head scarves off two girls. The month before, a national controversy erupted after a public swimming pool in Copenhagen created girls­only lessons in response to Muslim requests.

“Freedom of speech is now interpreted as freedom to say anything hateful,” said Julie Jeeg, a law student who volunteers with an anti­racism group. “Denmark is closing in on itself. People are retreating inward.”

Witness the “meatball war.”

In January, after revelations that a Randers day care center had stopped serving pork meatballs since its Muslim students would not eat them, the Town Council narrowly passed a measure requiring that pork be served “on equal terms with other kinds of food.” The councilman who pushed the measure, Frank Noergaard of the Danish People’s Party, said he was incensed that “pork

Follow SaveMySweden