Miigrants wait in an exclusion zone for transport to a registration office at the State Office of Health and Welfare in Berlin in October 2015. (Markus Schreiber/Associated Press)

Constanze Stelzenmüller is Robert Bosch senior fellow at the Brookings Institution.

Germany is about to embark on a radical social experiment. It will determine whether the huge wave of refugees that washed over Europe last year will be a boon to the continent, or a catastrophe. No wonder Berlin’s legendary air (celebrated in the unofficial city anthem “Berliner Luft”) feels particularly bracing these days.

Last week, Germany’s legislature debated a new law on integration, the country’s first. It requires asylum seekers to take lessons in language, culture and values in exchange for faster access to the labor market. The government has promised to subsidize 100,000 new “working opportunities,” many of them low-paid workfare jobs. Labor laws will be relaxed to make hiring refugees easier.

But newcomers without a job will have to stay in the municipality first assigned to them. Those who reject these rules face cuts to their support. Interior Minister Thomas de Maizière said ominously: “They will not do well here.”

The purpose of these new measures is to prevent the rise of parallel societies as in Belgium or France — or the ghettos that sprang up in large German cities after the arrival of hundreds of thousands of Turkish “guest workers” beginning in the 1960s. No effort was made to nudge or pressure them to integrate; Germany’s restrictive citizenship laws, a pre-World War I holdover, made it very difficult to get a passport. The German left sanctimoniously justified this neglect as “multiculturalism.” The right calculated it would make people leave.

Many Turks put down roots anyway. Now, an estimated 1.5 million German citizens have a Turkish background, despite German governments insisting for decades that ours would never be an immigration country. Ghettos and alienation still persist; in April, the International Center for Counterterrorism in The Hague reported that more than 700 foreign fighters in Syria have come from Germany.

Yet there are now also government officials, legislators, filmmakers, writers, soccer stars and standup comedians with Turkish names. Together with a significant influx of war refugees and economic migrants from around the world, of Jews and ethnic Germans from the former Soviet Union, they have already changed the face of my country.

The Germany I was born into — white, and Catholic or Protestant — is a memory. More than 20 percent of its current inhabitants came to us as migrants, or are the children of migrants. My own extended tribe (lily-white and Lutheran for centuries), over two generations has acquired Swiss, American, Taiwanese, Jewish, Senegalese and Ghanaian-Slovene family members. Heck, some of us even married Catholics.

Today’s challenge, however, is on an entirely different level, not just because of its size. Refugees from war zones such as Syria and Afghanistan are often severely traumatized. Acquiring the skills and knowledge to fit into Germany’s economy and society will be hard for many. Those who are not bona fide refugees will have to be sent back.

The biggest surprise of the great refugee wave of 2015 was how German institutions were swamped, and how citizens calmly stepped in to help the new arrivals. Most of us would have expected it to be the other way around. But now civil society is overwhelmed, and the populist party Alternative for Germany (AfD) is capitalizing on widespread anxiety and anger. Chancellor Angela Merkel’s adversaries are circling her, probing for weak spots.

The chancellor rightly resists caps to the asylum right in Germany’s constitution. But in pragmatic Merkel fashion, she has accepted controls at Germany’s borders and made a deal with Turkey (billions in aid in return for keeping refugees away from Europe). Balkan countries sealing their borders has helped to stanch the migrant flow.

But migrants are still attempting by the thousands to cross the Mediterranean — now via Libya — and often dying in the attempt. German police recently arrested suspected members of an alleged Islamic State terrorist cell, possibly foiling a plot to commit a major terrorist attack. All three were Syrian and had come to Europe as refugees.

A senior civil servant in Berlin told me recently: “All this will completely change the face of Germany.” But for this experiment to succeed, it will have to reinforce the capacities of communities and regions to turn the new arrivals into productive and peaceful members of society. It will have to reinforce and link up the domestic intelligence and security services — while increasing oversight and accountability. Germany will also have to develop a much more comprehensive and forceful foreign policy for Northern Africa and the Middle East. Last but not least, it needs to do better at ensuring the solidarity of its fellow European Union member states.

That’s a tall order, even for a state as powerful and wealthy as Germany. But failure would be a disaster for Europe, and for transatlantic relations. A lot rides on Berlin getting it right — not least for the United States. Although you wouldn’t know it from watching this U.S. election campaign.