Every July, Sweden provides one of the world’s great democratic displays. Politicians of all hues descend on the Baltic island of Gotland for the annual Almedalen festival (1-8 July), meeting voters and debating issues ranging from forestry and fake news to immigration and imams in schools.

But in advance of the general election on 9 September, a spectre haunted this year’s Almedalen. Swedish politics is facing its most severe test for decades. The consensual, egalitarian model that has attracted global admiration is under immense strain.

The most notable sign is the surge in support for the populist, anti-immigration Sweden Democrats. Opinion polls suggest the far-right party could potentially double its 2014 vote share (13 per cent), which made it the country’s third-largest party with 49 seats. It is even conceivable that the Sweden Democrats, who recently backed a referendum on EU membership (“Swexit”), could finish first.

The nationalist outfit’s rise has been accompanied by a collapse in support for traditional parties. Sweden’s ruling Social Democrats were once electorally hegemonic, governing for more than 60 years of the 20th century and averaging 45 per cent of the vote (twice exceeding 50 per cent). For the last four years, the party has led a minority government in alliance with the Greens. But in common with their German, French and Italian counterparts, the Social Democrats are now struggling and are on course for their worst result for more than a century (a recent YouGov poll put them on just 22 per cent).

The centre-right opposition, led by the Moderate Party (on 17 per cent), is faring no better. A four-party alliance, that governed from 2006 to 2014 and passed radical free market reforms, is in danger of fracturing.

How did Swedish politics enter such a disruptive era?

For more than a decade, the main parties established a cordon sanitaire around the Sweden Democrats. They were entirely ostracised, gaining no positions of influence in the Riksdag, the Swedish parliament, after their breakthrough in 2010 (when they won 20 seats). Many of their policies – including an EU referendum, which a majority of Swedes oppose – have been stubbornly resisted by other parties.

Such a stance reflected the Sweden Democrats’ history. The party’s roots lie in the neo-Nazi movement – an early slogan was “keep Sweden Swedish”. But the far right has since sought to detoxify its image. Jimmie Åkesson, the leader of the Sweden Democrats since 2005, has periodically purged its more extreme members. The rebrand, however, has not always succeeded. A local Sweden Democrat politician was forced to resign last year after suggesting Muslims were not fully human. And the MP Björn Söder, a leading member of the party, recently caused consternation by suggesting that Jews and Sami people were not true Swedes.

Yet support for the Sweden Democrats has steadily increased since the last election. The party’s biggest surge followed the 2015 EU refugee crisis. That year, 163,000 asylum seekers arrived in the country of ten million – one of the highest proportions in the EU relative to population size. A total of 350,000 refugees have emigrated to Sweden in the last four years.

But the Sweden Democrats’ support later fell after the centre-left government imposed tighter controls on non-European immigration, with prime minister Stefan Löfven conceding that the country had been naïve (a shift which mirrored that of the Danish Social Democrats).

What, then, explains the Sweden Democrats’ renewed rise? The overriding cause is a sense of political malaise. The current minority government is the weakest for decades, unable to pass most of its policies through parliament.

“It has been on autopilot for some time,” Nicholas Aylott, associate professor of politics at Södertörn University, told me. The opposition has also been largely absent, reaching a much-loathed agreement to allow the government to pass its budgets in full (denying the Sweden Democrats any chance of parliamentary influence).

All parties, including the Social Democrats, have hardened their rhetoric on immigration and law and order as shootings, gang violence and even grenade attacks have become frequent occurrences. Aylott points to the pan-European trend of populist parties stealing votes from the centre left because of their focus on immigration: “You can understand why the Social Democrats changed [their] position so drastically on this because it’s clear where a lot of the Sweden Democrats’ vote comes from.” But the crackdown on immigration has not been uniform. Last month, the government aligned with some liberal and conservative MPs to pass a bill granting 9,000 unaccompanied minors, who arrived in 2015, a second chance to apply for asylum if they remained in education.

The final cause of the Sweden Democrats’ rise is the disunity of the centre-right opposition, which ought to be advancing towards power but is instead marked by divisions. Most recently, a fractious debate has broken out over whether to allow Sweden Democrat MPs to become chairs of parliamentary committees.

Behind all this lies the fear that Sweden could become all but ungovernable after the election. The centre left and centre right are expected to each receive around 40 per cent of the vote – but should the Sweden Democrats win 20 per cent or more, they will be empowered to block prospective governments. A German-style grand coalition between the left and right has been ruled out by both sides, but nobody has suggested how the impasse would be resolved.

Aylott suggests that Ulf Kristersson, the Moderate Party leader and the most likely next prime minister, is emulating Theresa May by refusing to outline how he would govern. “He is trying to procrastinate and just hope that something turns up to help him solve the problem another day.”

Richard Milne is the Financial Times’s Nordic and Baltic correspondent