Andersson, the current finance minister, will replace Stefan Löfven.
Swedish MPs have voted to make Magdalena Andersson the country's first female prime minister.
After days of uncertain negotiations, the Social Democrat leader secured the support she needed in parliament on Wednesday morning.
An agreement was reached on Tuesday evening with the Left Party, which was demanding a pension increase in order to secure their support.
Andersson, the current finance minister, had been set to replace Stefan Löfven as PM but until Tuesday had failed to secure enough support among MPs.
Last week Andersson asked for more time to secure the support of the Left Party after intensive talks reached an impasse.
She was given until Monday this week to find enough backing in the 349-seat Riksdag parliament.
She needed to secure the backing of the two smaller parties that supported Sweden's previous centre-left, minority government led by Löfven.
The other ally, the Center Party, has already said its lawmakers will abstain from voting against Andersson.
Under the Swedish Constitution, prime ministers can govern as long as a parliamentary majority — a minimum of 175 lawmakers — is not against them.
The Social Democrats currently hold 100 seats and the Greens have 16 seats. Together with their allies, they have a total of 174 seats.
The right-wing of the Riksdag is divided. Ulf Kristersson, head of the opposition Moderate party — Sweden’s second-largest — repeatedly has said that a centre-right government is not feasible because no mainstream party wants to cooperate with the third-largest Swedish party, the right-wing populist Sweden Democrats, which is rooted in a neo-Nazi movement.