The bloc, headed by the Social Democrats' leader Magdalena Andersson, was expected to win 175 seats in the 349-seat parliament, the Riksdag, based on votes from 5960 of Sweden's 6312 election districts, the election authority said on Monday.
The right-wing governing bloc of Prime Minister Ulf Kristersson was seen winning 174 seats, with ballot-counting continuing.
The election, while unlikely to change the course of Sweden's pro-Western and pro-Ukraine stance, could decide whether Kristersson's push toward a hard-right clampdown on migration continues or even accelerates.
Given the closeness of the race, the winner may not be known for several days, after all overseas ballots have been counted.
In a pre-election pledge, Kristersson broke a longstanding taboo and said he would bring into government the Sweden Democrats, a far-right party with roots in the neo-Nazi fringe, as he aims to create a majority-right coalition.
Many voters on the right say a win would amount to an endorsement of policies that have helped to curb gang violence and cut immigration dramatically.
But some in the Nordic nation of 10.6 million have expressed wariness, saying Kristersson's invitation to the far right was a step too far.
Kristersson's critics also say his immigration policies, with incentives and penalties that pressure migrants either to conform more closely to Swedish cultural norms or leave the country, are undermining civil liberties.
Kristersson has trailed in opinion polls throughout his four years in office but had been catching up in the final weeks of campaigning, while Andersson and her Social Democrats lost ground.
Hours after voting had ended, Kristersson said he held on to hope that he could still cobble together a majority among the eight political groupings that secured seats in the Riksdag, saying his party's economic policies were more popular than the opposition's.
"Even if tonight's results hold, I will explore whether it's possible to find a viable government constellation ... capable of securing support for the fiscal policy Swedish voters have voted for," he said.
Andersson's bloc is riven with differences over issues from migration, where she wants a more restrictive line than do some of her partners, to a tax on billionaires and construction of new nuclear reactors.
Her budgets may also struggle to find support given that the Left Party, Sweden's former Communist party, and the Centre Party, which favours free-market policies, do not see eye-to-eye on many economic issues.
Electoral success for the Sweden Democrats would be welcomed by Europe's ascendant far-right parties, which were bolstered by the anti-immigrant Alternative for Germany's win in a German state election last week.
The far right hopes for gains in upcoming elections across Europe, with the National Rally's campaign for the French presidency next year potentially its biggest prize.
with Reuters