The storied city of Weimar, Germany (population 65,000), absorbed 900 refugees in a year. Our journalists spent months on the ground examining integration from all sides.

‘True integration only comes when both sides are willing to move.’

‘We thought we were coming to a free country, and here is this guy telling us how we should be dressed.’

‘I cannot take the other culture with a spoon and eat it and get it inside me.’

So it went in a four-month cultural crash course pairing Weimar residents with refugees, and in informal interactions around the city and the rest of Germany, as roughly one million people arrived in galvanic waves from Syria, Iraq, Afghanistan and elsewhere. The rapid influx shook European social structures, accelerated a rise in right-wing nationalism and saddled social welfare systems with the complex challenge of absorbing so many desperate wanderers at once.

He scoffed: “Of course they can worship in the mosque. This is a misconception. There is a separate section in the back for them.”

She pressed on: “I have heard that women can’t worship in the mosque. Is this true?”

The Syrian man, one of 900 asylum-seekers welcomed in Weimar, Germany, was no less upset. “Have you asked them?” demanded Anas Alkarri, 28. “I think you will find it is their choice to wear the hijab.”

The German woman , herself an immigrant from Ghana, jerked forward with such force her hoop earrings swung like pendulums. “The whole thing is to have power over women,” declared Mona Fofie, 24, speaking of the Muslim head covering called hijab.

Map of Weimar, Germany Hamburg Berlin GERMANY Cologne Weimar Frankfurt Munich 100 miles

Germany led the way in numbers of refugees and in programs to support them, as Chancellor Angela Merkel called for constituents to open their communities and, not incidentally, provide work in a nation where 658,000 jobs went unfilled last year.

The German government spent 14.5 billion euros — about $15 billion — on refugees in 2016, and nearly as much is earmarked for this year. About $1.5 billion of 2016’s expenditures paid for reception centers, registration and housing during the asylum application process; $2.2 billion went to integration efforts like the cultural crash course run by the European Youth Education Center in Weimar.

With the anti-immigration Alternative for Germany party polling as the third-strongest ahead of federal elections in September, the nation’s Interior Ministry released figures this week showing that the number of criminal suspects classified as immigrants had surged more than 50 percent. Nearly 175,000 newcomers to Germany were charged last year, according to the data, accounting for 8.6 percent of all crimes, up from 5.7 percent in 2015, increasing the pressure on Ms. Merkel’s government to step up deportations of illegal or criminal immigrants.

“Those who commit serious offenses here forfeit their right to stay here,” warned Thomas de Maizière, the interior minister.

In Weimar, a storied center of culture and politics that bridges the nation’s old East-West divide, Ralf Kirsten, the police chief, said many of the crimes involving Muslim newcomers consisted of disputes among themselves and frustrations over living in communal housing, not attacks on Germans.

The city settled the migrants with classic German efficiency and astonishing speed by all measurable criteria: They were housed, clothed and fed, the children enrolled in local schools and the adults in government-paid classes to learn the basics of the language, laws and customs.

They had health care, first through a new refugee department in the city government and then, once they were granted official refugee status, through the social service channels used by all Germans. That status also meant their monthly stipends increased to €409 ($434) from €216 ($230) for single adults, with a young family of three receiving €605 ($643).

Migrants to Germany Are Young and Mostly Male Male Female Age 0-4 4-6 6-11 11-16 16-18 18-25 25-30 30-35 35-40 40-45 45-50 50-55 55-60 60-65 65+ Age and gender distribution Asylum applicants Germans 20% 15 10 5 5 10 15 Share of the total population Age and gender distribution Male Female Age 0-4 4-6 6-11 11-16 16-18 18-25 25-30 30-35 35-40 40-45 45-50 50-55 55-60 60-65 65+ Asylum applicants Germans 20% 15 10 5 5 10 15 Share of the total population Note: Age and gender distribution of asylum applicants in 2015 and 2016 compared with Germany’s total population. Sources: Germany’s Federal Office for Migration and Refugees and Federal Statistical Office (Destatis)

But on the person-to-person level where integration really happens, there are staggering cultural headwinds. On issues like gender, sexuality, religion in the public sphere and even the seemingly mundane matter of punctuality, the differences may take generations to overcome.

A city of 65,000, Weimar sits in a region of gentle hills and poor but picturesque villages, the narrow Ilm River flowing through the shadows of old palaces and sprawling parks.

Two of Germany’s dominant literary figures, Goethe and Schiller, lived here. The Weimar Republic, which rose and fell between two world wars, was formed here, as was the influential 20th-century design movement Bauhaus. From September 2015 until February 2016, asylum-seekers like Anas arrived weekly by the busload. They crammed into a dormitory on Weimar’s western edge and eventually fanned out to apartments of their own to start new chapters.

Besides the housing and government-provided food or stipends, Weimar’s refugees found a plethora of student, religious and social service groups providing help navigating the German bureaucracy and offering activities and events to pull them into the life of the city.

Dozens of refugees we met said they had been largely welcomed — or ignored — though many recounted moments of public hostility and even physical aggression. As the months passed, we watched them wandering the cobbled streets of Weimar’s old city, pushing bicycles, pausing at kebab shops, playing table soccer with shaggy university students.

“I think this process of integration is going to be more difficult than people realize,” Anas said one day. “And I think it will come as a surprise to many of the Germans, but it is going to be just as hard for them as it is for us.”