0246 GMT November 29, 2021
Andersson will succeed outgoing Prime Minister Stefan Lofven after a total of 117 members of parliament voted for her, while 57 abstained, 174 voted against and one was absent, according to AFP.
Under Sweden's system, a prime ministerial candidate does not need the support of a majority in parliament, they just need to not have a majority – or 175 votes – against them.
The 54-year-old, who took over as leader of the Social Democrats earlier this month, reached a deal with the Left Party late on Tuesday to raise pensions in exchange for its backing in Wednesday's vote.
She had previously received the support of the Social Democrats' coalition partner the Greens, as well as the Centre Party.
However, Andersson faced her first setback even before her election on Wednesday.
The Centre Party announced that while it would not oppose Andersson in the vote for prime minister, it would withdraw its support for the government's budget to be voted on later Wednesday, due to the concessions made to the Left.
That means Andersson will in all likelihood have to govern with a budget presented by the opposition conservative Moderates, Christian Democrats and far-right Sweden Democrats.
Andersson will formally take over her functions and present her government on Friday.
Lofven resigned on November 10 after seven years as prime minister in a widely expected move aimed at giving his successor time to prepare for the country's September 2022 general election.
Despite being a nation that has long championed gender equality, Sweden has never had a woman as prime minister.
All other Nordic countries – Norway, Denmark, Finland and Iceland – have seen women lead their governments.