Stockholm is burning. Yes, Stockholm, the Swedish capital, is in flames, after hundreds of immigrant youths rampaged through the streets for four straight nights, torching cars and buildings, hurling rocks through windows, and attacking police.

The chaotic scenes are at odds with Sweden's reputation as a liberal model of prosperity, social security, and openness. The riots reportedly started in reaction to Swedish police killing a 69-year-old machete-wielding man earlier this month. But the ferocity and duration of the violence has shocked locals, who say they're at a loss to explain it.

"It's difficult to say why they're doing this," Selcuk Cekenhe, who works at a youth center in one of the affected suburbs, tells NBC News. "Maybe it's anger at the law and order forces, maybe it's anger at their own personal situation, such as unemployment or having nowhere to live."

Some analysts say the explosion this week has exposed an ugly side of Sweden that has long festered beneath the surface. Niklas Pollard and Philip O'Connor of Reuters say Sweden's generous welfare model — with its 480 days of parental leave for each child — has overshadowed deep resentment between native-born "haves" and newly arrived "have-nots."

Some 15 percent of the population is foreign born, the highest in the Nordic region. The rise of the anti-immigrant Sweden Democrats party, which has called for a curfew in response to the violence, has polarized Swedes.

Metros and trains out of Stockholm center late at night are full of exhausted-looking Arabic- or Spanish-speaking immigrants returning home from menial jobs. Even second generation immigrants struggle to find white collar employment.

As one Asian diplomat puts it: "On the one hand Sweden has all these immigrants. On the other hand, where are they? It sometimes seems they are mostly selling hotdogs." [Reuters]

The worst of the rioting — Sweden's worst unrest in years — has occurred in heavily immigrant neighborhoods, mainly the Husby suburb of Stockholm. According to Elias Groll at Foreign Policy, this indicates that the violence is "clearly a symptom of Sweden's failed effort to integrate its massive immigrant population."

Housing segregation is rampant in the country, and Husby is a case study in how immigrant populations have come to dominate Stockholm's outer suburbs... Depending on your political perspective, native-born Swedes have either fled Husby or been pushed out by immigrants.

Husby also suffers from rampant unemployment — a problem that is particularly acute for its youth. Nearly 30 percent of the city's young people are neither employed nor actively enrolled in school, a number that mirrors a broader trend of immigrant underemployment relative to the native-born population. [Foreign Policy]

The government's response doesn't appear to be helping matters. Witnesses say riot police — wielding clubs and leading snarling dogs — have hurled racial insults at the rioters, calling them "monkeys" and "rats."

"I can understand the police officers were stressed, but this language is unacceptable, and unfortunately nothing new," Rami al-Khamisi, a law student, told The Local.

Khamisi said the government's heavy-handed response is unlikely to restore calm. "We're seen as a problem that politicians want to solve by sending more police," he said. "This is not a solution we agree with."

The rioting has already raised questions about Europe's struggle to assimilate its large immigrant populations. Because if violence can break out on the placid streets of Stockholm, it could seemingly break out anywhere.