Donald Trump’s outburst about “that thing that happened in Sweden last night” – which turned out to be a Fox News report he had seen on the difficulties of integrating refugees – is only the latest illustration of the role that Sweden plays in the fantasies of the outside world.

The wonderful thing about Sweden is that you can believe what you like about it. For much of the 20th century it was a place where foreign progressives could only believe that everything ran perfectly smoothly and everyone got laid, thanks in part to the exploits of Ingrid Bergman and the Swedish arthouse film I am Curious (Yellow). In the 21st century it has become the country where foreign rightwingers can believe that nothing works and that rape is widespread.

Trump is not the first American president to use Sweden to prove a domestic point. In 1960, the president, Dwight Eisenhower, gave a speech to a Republican breakfast meeting at which he said that Sweden “has a tremendous record for socialistic philosophy, and the record shows that their rate of suicide has gone up almost unbelievably and I think they were almost the lowest nation in the world for that. Now, they have more than twice our rate. Drunkenness has gone up. Lack of ambition is discernible on all sides”.

This was complete nonsense, except, perhaps, for the point about drunkenness: Sweden had only abandoned prohibition-era alcohol rationing in 1955, five years before he spoke. But even though Eisenhower’s comments drew on no known Swedish sources, they were entirely harmless nonsense compared to the current president’s.

Trump, on the other hand, was drawing on a persistent set of myths among Sweden’s nationalist right, which claims that Muslim immigration has turned some urban areas into ghettoes where sharia law is practised, gang rape is commonplace, and the police and fire engines hardly dare to go. This is a grotesque distortion of a worrying reality. There has been a huge rise in recorded violent crime in Sweden in the last 40 years, but it is still a very much safer place than the US, UK and indeed most of Europe. There has been a huge increase in humanitarian immigration. But it’s not clear how the two are related.

I used to live in one of these supposed ghettoes in the early 1980s, when it was still largely white and the nearest we got to criminality was when my friend the bootlegger made vodka in his kitchen. When I went back 20 years later, there was a Somali family living in my old flat, and almost all the children playing in the open spaces around it were supervised by women in headscarves. I was with a radio producer who talked at length in Arabic to an Iraqi refugee who had been resettled there after a hellish journey.

But there was absolutely no feeling of danger or hostility. Similarly, Rosengård, the suburb of Malmö which is portrayed in the rightwing press as Sweden’s answer to Mogadishu, is far more open and peaceful than, say, the rougher parts of north London.

That said, there are pockets of serious criminality in the most segregated parts of Sweden. These are fuelled most by the easy availability of guns after the Balkan wars, and by disputes in the drug trade. Kossovar, Bosniak and Turkish gangs, along with Scandinavian bikers, have engaged in bloody street wars. Three young people were shot dead in their car about 500m from where I used to live in Uddevalla two years ago: the killers were a couple of Lebanese brothers. There is one suburb of Gothenburg divided between two rival Somali groups.

Almost all of this criminality arises from second generation immigrants, when they are immigrants at all. When I was last in the country, I spoke at length to a very senior policeman in Gothenburg, and his view was that this was a problem caused by adolescent males, unemployment, exclusion from the communities around them, and easy access to guns. Religion had nothing to do with it.

We were talking in the shadow of a hideous murder in one of the most segregated communities in Sweden, where two schoolchildren and a teacher had been killed with a sword by a young man dressed up as a stormtrooper. He was white, and his victims were not – and were chosen for exactly that reason. To the extent that there is serious ethnically motivated crime in Sweden, it appears that the immigrants are the victims as much as the perpetrators, whatever Trump may think.