Sweden’s left wing opposition won a narrow majority in the country’s general election after the vote count ended Thursday, but faces laborious negotiations to form a government.

The four parties in the left-wing bloc, led by Magdalena Andersson’s Social Democrats, hold a three-seat majority in the 349-seat parliament over outgoing prime minister Ulf Kristersson’s right-wing alliance, which includes the anti-immigration Sweden Democrats.

But only around 50,000 votes separated the two sides in the country of 10.6 million people.