NASTEHO WEHELIYE sits on one side of a semi-segregated cafeteria (men-only to the right of the counter; mixed to the left) in Tensta, a migrant-heavy suburb of Stockholm. Like many Somalis, she is an enterprising soul. So it is hardly surprising to hear her lament the high taxes and hiring costs of the homeland she adopted as a young asylum-seeker 27 years ago. As she wrings her henna-stained hands at the thought of the regulations that have stymied her two attempts to open shops in the Swedish capital, the café owner parks himself at a neighbouring table in an ill-disguised effort to eavesdrop.

The biggest local problems are housing and unemployment, says Ms Weheliye. These challenges have acquired fresh urgency as Sweden confronts the massive task of integrating its latest wave of refugees. In 2015, 163,000 asylum-seekers, mostly Syrians, Afghans and Iraqis, reached the country. Relative to Sweden’s population of 10m, this was the largest influx ever recorded by the OECD, a club of mostly rich countries. Not all will stay; last year two-fifths of asylum claims were rejected. But the rest will need homes, schools and jobs.

Tensta shows why that will be hard. In recent decades waves of migrants and refugees have filled its high-rises after native Swedes upped sticks for better areas. Today Tensta is one of 53 parts of Sweden that the police deem “vulnerable” (ie, crime-ridden). Unemployment is substantially higher than the national rate of 6.6%. Development schemes have eased tensions, says Ditte Westin, a local official and former policewoman who has known the area for 20 years. But a quick tour of the neighbourhood, under the deafening sound of a police helicopter, reveals some of its scars, from open drug-dealing to a basketball court that, Ms Westin jokes, is used mainly by kids fooling around on motorbikes.

Just 6% of Swedes live in areas like Tensta, according to Tino Sanandaji, an economist, but 26% of residents with a non-Western immigrant background do. Their troubles are milder than those of some American inner cities or French banlieues, but hard to swallow for a society that prides itself on order. To avoid deepening segregation, ministers know they must act now, as the asylum system churns through the new claimants. A new law obliges all 290 of Sweden’s municipalities to accept refugees, but as they can go where they like once their claim is granted, clustering is hard to avoid. A housing shortage, particularly in Stockholm, aggravates the problem.

Finding work for refugees is another tough nut to crack. Fully 95% of new jobs in Sweden require at least a secondary education; one-third of recent refugees, most of them women, have less than nine years’ schooling. High wage settlements, agreed between unions and employers, make it hard for unproductive workers to find jobs. The employment gap between low-skilled migrants and natives, nearly 20 percentage points in 2012, is a persistent feature of the labour market. And the concentration of refugees among Sweden’s immigrants presents a challenge that will only have been sharpened by the recent influx.

Immigration also shoulders some of the blame for a decline in education standards (as measured by PISA scores) and a growth in inequality—admittedly to levels that remain the envy of less cohesive societies. Successful, high-trust countries like Sweden are vulnerable to this sort of difficulty: they may be happy to welcome outsiders, but can be harder to penetrate than looser, more informal places. It is hard to create an inclusive national identity under such circumstances. All seven of Ms Weheliye’s children were born in Sweden, she says, but few of them feel Swedish.

All this prompts a harsher criticism: that its wealth has allowed Sweden to prop up an ethnic underclass sequestered in invisible suburbs. Alert to the concern, business groups and some politicians argue for a disruption of Sweden’s wage-setting model to encourage a fresh wave of lower-paid service-sector jobs; flexible America, they note, is good at putting unskilled migrants to work. But sceptics fear this would entrench an ethnically stratified labour market. Better to focus on teaching refugees skills and Swedish, and hurry them into better-paid jobs, they say. The debate is likely to dominate next year’s election campaign.

Sverige, vart ska du?

Beyond the policies lies a more nebulous question: what sort of country does Sweden want to be? The old consensus has broken down, perhaps for good. A country that defined itself through the welcome it extended to outsiders is now consumed by the task of managing those who came. Border controls imposed in 2015 remain in place, and there is no appetite to return to the open-door policy of the past. “We want to help as many people as we can,” says Morgan Johansson, the migration minister. “But there are limits.” Such thoughts once approached heresy in Sweden.

One casualty is the cordon sanitaire around the Sweden Democrats, a rabble-rousing anti-immigrant party of the sort disrupting politics across Europe. In January the centre-right Moderate Party said it would work with the Sweden Democrats in certain circumstances. The move led to a sharp drop in the Moderates’ popularity, but it will be hard for mainstream parties to lock out the populists for ever. The Sweden Democrats nabbed 13% of the vote in 2014, forcing the Social Democrats to assemble a minority government, and polls now give them around 20%.

The situation is hardly hopeless. Swedish firms are desperate for workers, and the influx of young newcomers will help in a greying society. Tightened borders have bought the government precious time. And the troubles of areas like Tensta have been exaggerated by outsiders with an anti-immigrant agenda. The question is whether Sweden can work out how to extend the benefits of the successful society it has built to those it has invited to join. The aim is laudable, but just now the odds look long.