Swedish Prime Minister Magdalena Andersson's left wing bloc was neck-and-neck with the opposition right-wing in Sunday's general election amid a far-right surge, with votes in more than three-quarters of electoral districts counted.
The right wing bloc was credited with a majority of 175 of 349 seats in parliament, with the left bloc trailing with 174.
Earlier, two exit polls had given the left-wing bloc a slim lead.
Conservative Moderates leader Ulf Kristersson, who is challenging Andersson for the post of prime minister, and two other smaller right-wing parties have for the first time tied up with the anti-immigration and nationalist Sweden Democrats, which looked set to post their best election score yet.
The far-right party was seen garnering around 20.7 percent of votes which, if confirmed, would for the first time make them the country's second-biggest party, overtaking the Moderates, the traditional leaders of the right-wing bloc.
The election campaign has been dominated by issues close to right-wing voters, including rising gang shootings, immigration and integration issues.
While Andersson's Social Democrats looked set to remain the country's biggest party with 30.4 percent, the Moderates appeared to slip to third position, with 19 percent.
That would be a heavy blow to Kristersson, who orchestrated a major shift in Swedish politics by initiating exploratory talks in 2019 with the Sweden Democrats, long treated as "pariahs" by other political parties.
The two other small right-wing parties, the Christian Democrats and to a lesser extent the Liberals, later followed suit.
- 'A nail-biter' -
Sweden Democrat party members gathered for an election-night rally erupted in cheers and waved party flags as the exit polls were flashed on to a large screen.
Party secretary Richard Jomshof told public television SVT he "didn't believe" that other parties would be able to freeze out his party again and expected to have a strong influence on Swedish politics.
"We are so big now ... it is clear we should have a spot on parliamentary committees", he said.
If the right-wing bloc were to emerge victorious, "we have a chance to be an active part of a government that would move politics in a completely different direction".
As votes were being counted across the country, Social Democrat party campaigner Mille Mikael Isberg told AFP the election race was "a nail-biter".
Prime Minister Andersson, a 55-year-old former finance minister, was vying to build a government with the support of the small Left, Centre and Green parties.
The Social Democrats have governed Sweden since 2014 and Andersson enjoys broad support among Swedes.
She consistently led Kristersson by a wide margin in opinion polls.
- 'Enormous shift' -
Both blocs are beset by internal divisions that could lead to lengthy negotiations to build a coalition government.
But for a number of reasons there is "pressure to have a united and effective government" in place quickly, said political scientist Katarina Barrling.
Sweden faces a looming economic crisis, is in the midst of a historic NATO application process and is due to take over the EU presidency in 2023.
The end of the Sweden Democrats' political isolation, and the prospect of it becoming the biggest right-wing party, is "an enormous shift in Swedish society", said Anders Lindberg, an editorialist at left-wing tabloid Aftonbladet.
Born out of a neo-Nazi movement at the end of the 1980s, the Sweden Democrats entered parliament in 2010 with 5.7 percent of votes. They won 17.5 percent in 2018.
The party's rise has come alongside a large influx of immigrants, with the country of around 10 million people taking in almost half a million asylum seekers in a decade.
It also comes as Sweden struggles to combat escalating gang shootings attributed to battles over the sales of drugs and weapons. Crime is seen as one of far-right voters' top concerns.
The country now tops European statistics for firearm deaths.
While the violence was once contained to locations frequented by criminals, it has spread to public spaces such as parks and shopping centres, sparking concern among ordinary Swedes in a country long known as safe and peaceful.