Watch: Parliament elects Andersson as Swedish PM for second time
The former finance minister won a similar vote last week but threw in the towel only hours later after the Green Party – a coalition partner – abandoned the government over a lost budget vote.
Ms Andersson will now form a minority government consisting only of her own party, the Social Democrats, which hold 100 seats in the 349-seat parliament and will have to rely on support from several other parties to implement policy.
Not since 1979 has a government commanded so little direct support in parliament.
“Like all minority governments, we will seek cooperation with other parties in parliament, and I see good opportunities to do so,” Ms Andersson told a news conference.
“The Social Democrats have the biggest party group in parliament by a wide margin. We also have a long tradition of cooperation with others and stand ready to do what is needed to lead Sweden forward.”
Complicating the picture, Ms Andersson will have to govern on a budget in part formulated by three opposition parties, including the anti-immigration Sweden Democrats, whose gains over the past decade lie at heart of Sweden’s political turmoil.
Her tenuous hold on power is due to a deadlocked parliament where neither the centre-left nor centre-right can form a majority on their own.
Ms Andersson served as prime minister for seven hours before stepping down last week after the Greens left her two-party coalition.
Their move followed the rejection of her government’s budget proposal in favor of one presented by opposition parties including the right-wing populist Sweden Democrats, which is rooted in the neo-Nazi movement.
Ms Andersson’s appointment as prime minister marks a milestone for Sweden, viewed for decades as one of Europe’s most progressive countries when it comes to gender relations, but which had yet to have a woman in the top political post.
In a speech to parliament, Center Party leader Annie Loof said a female prime minister "means a lot to many girls and women, to see this glass roof shattered”.
Watch: Why do we still have a gender pay gap?