Sweden's center-left parties held a slim lead over the rival center-right Alliance in the Nordic country's general elections, a voter poll by national broadcaster TV4 showed on Sunday.
The polls showed the far-right, anti-immigration Sweden Democrats would get 19.1% of the votes.
As he cast his ballot in Stockholm on Sunday, Lofven urged Swedes not to vote for the "racist party". In Strangnas, an hour west of Stockholm, Lofven's main challenger, Moderates leader Ulf Kristersson, handed out campaign leaflets in his hometown on voting day.
Sounding sombre and firm, Lofven told his supporters the election presented "a situation that all responsible parties must deal with", adding that "a party with roots in Nazism" would "never ever offer anything responsible, but hatred". We must gather all good forces.
"This government we have had now. they have prioritised, during these four years, asylum-seekers", Mr Akesson said, giving an exhaustive list of things he says the government has failed to do for Swedish society because of migrants.More news: Gary Neville: 'Harry Kane should have been rested'
The final results of the elections will be announced on Wednesday, after the roughly 50,000 votes cast overseas have also been counted.
It is highly unlikely that any single party will get a majority, or 175 seats.
It was uncertain however if Lofven, who heads one of the few left-wing governments in Europe, would be able to rustle up enough support in parliament to form a government.
Sweden - home to the Nobel prizes and militarily neutral for the better part of two centuries - has been known for its comparatively open doors to migrants and refugees.
Sunday's election is Sweden's first since the government in 2015 allowed 163,000 migrants into the country of 10 million.More news: Wind, rain, surge, flood: Hurricane Florence could hit hard
Lofven eventually said Sweden no longer could cope with the influx and immigration laws were tightened.
The Sweden Democrats are bidding to become the biggest populist party in the Nordic region, topping the Danish People's Party, which gained 21 per cent in 2015, and trump the 12.6 pe rcent for the far-right Alternative for Germany, which swept into the Bundestag a year ago. Members known for making pro-Third Reich statements were pushed out.
The Sweden Democrats - led by Jimmie Akesson - has worked to soften its neo-Nazi image while helping to break down longstanding taboos on what Swedes could say openly about immigration and integration without being shunned as racists. "We're now competing against the Social Democrats and Moderates to become the biggest party in the country", he said, dismissing the protesters as "communists". "We are the guarantee to oust the current government from power", he said.
Mattias, a Stockholm resident at an election night party in the city, said he was "extremely concerned" about the far right's steady climb since it entered parliament in 2006 with 5.7 per cent.More news: Aaron Rodgers Leads Packers to Comeback Win After Dramatic Return from Injury