“For me, it is about respect, but I also do not want to lead a government where there may be grounds to question its legitimacy,” Ms Andersson told a news conference.
She added: “A coalition government should resign if a party chooses to leave the government. Despite the fact that the parliamentary situation is unchanged, it needs to be tried again.”
Her resignation was a shocking twist in a dramatic and historic day in Swedish politics. Hours earlier, the Swedish parliament had approved Ms. Andersson as the country’s first female leader after she recently became the head of the ruling Social Democratic Party.
With the budget vote approaching, Ms. Andersson had said earlier on Wednesday that she would not resign if she lost, but changed her mind later in the day.
“I am of the opinion that [the opposition budget] as a whole is something I can live with,” Ms Andersson had told reporters at a news conference.
Her appointment was initially a notable milestone for Sweden amid gender equality as the country was yet to have a woman in the top political post.
Andersson had been tapped to replace Stefan Lofven as party leader and prime minister, roles he relinquished earlier this year.