The following correction was published on 22 September 2010: We suggested that the rightwing, Danish people's party, is in power in Denmark. It is not. The Danish Conservative Party and the Danish Liberal Party form the government. We also reported that David von Arnold, a Sweden Democrat party candidate, had been attacked by men of an Arab appearance who had carved a swastika in his forehead. However Swedish police have released a doctor's report that suggests the wound may have been self inflicted (A far-right party could hold the balance of power, 18 September, page 14 Weekend

_______________________________________________________________

The Swedish Social Democrats are no ordinary party. If Mona Sahlin, their leader, loses tomorrow's election, as seems almost certain, she will become the first leader in the party's history never to have been prime minister. The party has been in government for 65 of the last 78 years, and in that time no non-socialist government has ever been re-elected. But today a far-right party that blames Muslim immigration for almost all the country's ills is poised to enter parliament and hold the balance of power. It already has members in local government across more than half the country. The local paper in Malmö, the country's third-largest city, publishes a Google Map marking all the shootings in the city – there have been 46 this year, though no one has been killed. What on earth is going on in this tranquil, ordered and progressive country?

If you believe the international rightwing press, the answer is simple, and has been since 2004, when Fox News made a special report on the subject: Sweden, and especially Malmö, has become a laboratory for the creeping Islamisation of Europe. The most common child's name there is now Muhammad; police dare not go into immigrant districts, where only sharia law is respected; and soon all the Jews will be driven from the city. All this, flecked with varying amounts of spittle, is recounted as fact on the net and in US papers.

Paulina Neuding, a neoliberal Swedish commentator, wrote in Rupert Murdoch's Weekly Standard, "Too many of the country's Arab immigrants have brought anti-democratic values from their home countries; values that neither 'dialogue police' nor the world's most generous welfare system has been able to cure. And [Sweden] is also becoming a symbol of a western country that is prepared to compromise with those values."

The centre for all this fear is the Rosengård estate in Malmö. It is the nearest Sweden gets to a slum. "It doesn't feel like Sweden at all," said a horrified sociologist in a nearby university. "There are cockroaches there! People live 12 to a two-room flat. No one should have to live like that." In early September, police searched the bedroom of a local teenager who had been acting drugged in public, and found a submachine gun. Then they let him go, because he was only 15.

About 25,000 of Malmö's 300,000 people live on the estate; the actual figure is unknown because of overcrowding in the worst section, Herrgården, where adult unemployment runs at 90% (it is 30% on the estate as a whole). Thousands of new immigrants arrive every year. Of the 1,200 students in the secondary school, eight are native Swedes.

Like almost everywhere else that immigrants live in Sweden, Rosengård was built in the late 60s and early 70s as model housing for workers. But whereas most of these new settlements were located five or 10 miles outside the cities they served, and separated from them by belts of forest or farmland, Rosengård is an integral part of Malmö. It lies within the inner ring road. You can cycle there in 15 minutes from the station.

A 2008 government report, which drew entirely on the experiences of teachers, police and social workers, described a place where Islamic orthodoxy was enforced by young thugs; women were forced to wear headscarves and children segregated in religious free schools. There was a small riot after one of the 20 or 30 unofficial mosques in cellars was closed when its lease was not renewed, and nastier riots when the Israeli tennis team played a Davis Cup match in the city last summer.

But this isn't Beirut or Baltimore. It isn't even Tower Hamlets. I was told at Lund University that a foreign graduate student who lived in Rosengård for a couple of years couldn't understand why anyone would call it a ghetto. He came from Liverpool. Certainly, I can't think of another slum in Europe that has broad, well-signposted cycle paths on which stately middle-aged women in headscarves pedal their groceries home.

The houses are for the most part low blocks arranged in squares around playgrounds, on a familiar Swedish model. Even in Herrgården, where there are a few boarded-up windows, the play areas are clean and well-maintained.

The shops have Arabic signage as often as Swedish. The greengrocer's has a huge Ramadan calendar outside, but in the middle of a bright afternoon there are a great many people eating and drinking in public. In the middle of the estate is a shopping centre where a headscarfed woman is collecting for orphans in Iraq, Gaza and Pakistan. She came to Rosengård 16 years ago and says her children are happy on the estate, too. Her stall is an interesting mixture of Swedish and Islamic charity: the language is all Swedish, but the money referred to as zakat. All the distribution, the signs explain, will be handled by the Nordic aid organisation, which will guarantee the money ends up being used peacefully and responsibly.

The Islamology department at Lund University reckons the number of active Muslims in Rosengård and Sweden generally is greatly overestimated. "Most Muslims in Sweden are as unobservant as the Christians," says department head Leif Stenberg. "If you count the number of worshippers in the mosques, there are seldom more than 300 in the big ones, even at Friday prayers. The smaller ones will have 100, if that."

No one in Sweden believes there is any serious terrorist threat there, but Islam has become the symbol of all that is strange and menacing and un-Swedish about immigration. There is a film on YouTube that sums it up perfectly. In an industrial-looking warehouse, an old woman pushes her walking frame bravely across the floor towards two bureaucrats dispensing piles of cash. The camera cuts back to show that alongside her in the gloom are other figures – but these are swathed in burkas, pushing prams. You realise the old woman and the Muslims are all racing to reach red handles that hang from the ceiling, like the emergency brakes on trains. One is marked "Immigration", the other "Pensions". "You have a choice," says a woman's voice. "On September 19 you can slam the brakes on pensions or slam the brakes on immigration. Vote for the Sweden Democrats."

This is the banned party political broadcast for the Sweden Democrats, which the commercial television channel refused to show on the grounds that it was illegal to stand for election and be so flagrantly against ideals of equality. Instead, the Sweden Democrats may show an ad that directs people to their YouTube site. It's typical of the way in which this deeply conservative party has used new media to circumvent the old.

In another publicity stunt, the party released a report claiming to prove, from government statistics, that immigrants were five times more likely than native Swedes to be convicted of rape. What the statistics actually show is that they are five times as likely to be investigated for rape, but experts point out that this may be due in part to racism in the criminal justice system, and that the absolute numbers are very small: when the Sweden Democrats claimed that 10% of the rapists convicted in their survey were Iraqi, they were talking about 12 men. If 0.04% of native Swedes are investigated for rape in one year, the corresponding figure for immigrants is 0.22%."

Though rural Nazis are a staple of Swedish crime fiction, a few do, in fact, exist. Some years ago, one was pointed out to me on the island of Tjörn: "Look," my friend Rolf said as we passed an old man pushing his bicycle uphill, "there's the only Nazi on the island." The day was very hot, but the old man was wearing a heavy black suit, white collar and tie. "He really believes it," Rolf said. "He can argue it all out logically, though I have got him to admit Hitler went a little far with the Jews."

There has always been a streak of romantic nationalism in Swedish life. For most of the Social Democratic years, it took a paradoxical form: people here believed Sweden was the best country in the world because it was the most internationalist. This led to a fantastically generous policy on asylum and integration. Nearly a third of Sweden's population today are either immigrants or the children of immigrants. There are more Iranians living in Sweden than there are Danes. In 2007, one small town outside Stockholm took in more Iraqi refugees than the whole of the US. Professor Jan Ekberg at Linné University has calculated that unemployment among immigrants means the excess cost of their welfare payments over the tax they pay is at least as high as the defence budget, and possibly 50% higher. Although all measurements show that Swedish tolerance towards immigrants is increasing, it's not surprising that there has been a backlash.

Thirty years ago, the Sweden Democrats were a tiny fringe group of straightforward fascists – openly racist skinheads and a few old ideological Nazis. Anti-immigrant sentiment then was concentrated on a short-lived but successful protest party that entered parliament with nearly 7% of the vote in 1991 and soon after imploded and disappeared in the 1994 election.

Two years later, a group of four nationalist students at Lund University joined the Sweden Democrats. They all came from the backwoods of the province of Skåne, the country's southern tip – in Sweden, "backwoods" is a literal term. "There are really three countries here," says Peter Ekelund, a Stockholm businessman. "There is the region around here, with companies like mine where everyone speaks English in the office all the time. There is an international region around Malmö, and another around Gothenburg. And then there are the elk – that's all the rest."

The forest and farmland goes on for hundreds of kilometres in the interior, broken occasionally by farms and small towns. I lived in such towns myself for five years as a young man, and the sense of isolation from the outside world was very deep. Stockholm seemed like a foreign country, in some ways farther than small-town America.

This is the background from which the new Sweden Democrats emerged. The young men from Lund had taken over the party entirely within 10 years. By 2005, one of them, Jimmie Åkesson, had become the party leader at the age of 26. He moved the party away from Nazism and some forms of racism, but they were still pariahs. "No one would vote for them because they were seen as fascist yokels," says Niklas Orrenius, a journalist who has studied the movement for years. To be a known member was to risk sacking from any kind of job. Far-left activists beat them up, on one occasion breaking into a party gathering with iron bars. Last Friday two masked men attacked David von Arnold, a party candidate in Malmö, outside his flat and carved a swastika into his forehead. The respectable media largely ignored this as it ignores the party as a whole.

"Most journalists detest them, so they don't write about them seriously," Orrenius says. Sweden is still an extremely conformist, authoritarian society, where opinion formers and politicians move together like a shoal of herring. The whole shoal can change direction in a flash, but not one herring dares swim anywhere on its own.

In the elections of 2008, opinion polls gave the party only about 1.8% of the national vote. In the event, it got 2.9%, which represented a huge breakthrough, because any party above 2.5% is eligible for state funding. In Skåne, it became the fourth largest party, and part of local government in many towns, but it was still well below the magic 4% threshold that would get it into parliament. Today it is now above that level in all the polls.

The party owes its success to an appeal that seems to cross political boundaries. Hostility to immigrants, especially to Muslims, is certainly a very large part of it, but its slogan for this election, "Tradition and Security", represents two things the Social Democrats once delivered (they always carried the Swedish flag in their May Day parades), but that no party has been able to offer convincingly since the economic storms of the mid-80s when the "Swedish model" went bankrupt.

None of the people who runs Sweden thinks these things will ever come back. All the herring agree the free market is the way forward. The result can be bewildering to English ears: Swedish Conservatives sounding to the left of New Labour when they talk about social mobility, Swedish Social Democrats sounding to the right of Cameron's Conservatives when they talk about the benefits of competition.

Ekelund speaks with unusual frankness, but his views are common: "Sweden is an export-dependent economy, and that is why it is the most successful in Europe. A company like Ericsson does business in 180 countries. It's unthinkable for them to go along with a politics of prejudice. Actually, we need far more immigration, not less."

A few hundred metres from his offices in central Stockholm, the Sweden Democrats have set out their stall. It's an electioneering tradition: all the parties set little wooden huts in the city's central square, where they hand out sweets and leaflets, and talk to voters. Most are as ignored as chuggers, but the Sweden Democrats usually have an angry group of schoolchildren around them.

Ulf Oscarsson, a sturdy man in his late 60s, is minding the stall when I enter. Why has he joined the party? "My daughter was the victim of a serious attempted rape by a Muslim minicab driver. Here, in the centre of the city. He was a married man with three children. When it came to trial, he got a two-month suspended sentence and a £700 fine. They told us we needed to have a certain sympathy for his culture. Well, shit on that."

Behind him, a poster asks, "Which do you want: bigger locks on your front door or bigger locks on the prison doors?"

Oscarsson doesn't want new laws; he just wants the laws that exist to be enforced. Nor is he racist, he says, and I believe him. It's obviously not true of all party members, but the belief that everyone should play by the rules is fundamental to the Swedish sense of justice. He is just as angry about a scandal in provincial local government that did not involve immigrants. Oscarsson claims 20% of the party's membership are immigrants, and while this seems improbable, they certainly have some. I saw a young Indian man running the stall when I passed it on the way to Ekelund's office.

Outside the hut, a group of teenagers in from the suburbs for the day are arguing with the Sweden Democrat on duty. Parand Saumloo, a 17-year-old Swede with one Iranian parent and one Bulgarian, is furious. "Of course you're racists," she says. "This country is full of it." Jabbing her finger, she asks, "When did you ever see a Swede behind the counter of a pizza joint? The country absolutely depends on immigrants. It's lunacy to cut down immigration."

But later it becomes clear she doesn't see herself as a pizza seller: her father is a psychologist, and that is the profession towards which she is studying. "I can even understand that we have to do something about the ones who just live on benefits," she says.

The respectable parties have all said they will not cooperate with the Sweden Democrats should they get into parliament. But if, or when, they do, the party will almost certainly hold the balance of power between the centre-right parties and the opposing bloc of Social Democrats, Greens and former communists. If they are kept out, perhaps by the defection of the Greens to the centre-right, they can convincingly portray themselves as the only real opposition in the country.

But they have no real policies, only longings. A friend who works in Ystad on what would be Wallander's local paper sums up the Sweden Democrats' programme: "They want to move to a country where there aren't any immigrants."

I doubt they will even manage to drag Swedish politics towards xenophobia the way their Danish counterparts, who now sit in government, have done. A tougher sentencing policy is possible. Better enforcement of existing rules on immigration, coupled with measures to ensure immigrant mothers go out to work and don't just live on child benefit, is already the policy of the Burundi-born minister of integration, Nyamko Sabuni. But, in the end, the Sweden Democrats' dream of a world of "tradition and security" cannot be fulfilled. It is a longing for an illusory past to replace the illusory future of endless prosperity and justice into which the Social Democrats seemed for years to be leading their country.