The first female prime minister in Swedish history resigned from office on Wednesday only hours after she was voted in, according to the Swedish government's Twitter account.

Magdalena Andersson, 54, had not yet officially become the leader of Sweden, which would have occurred after she met with the king, CNN reported.

She resigned after her minority coalition’s budget was defeated in a parliamentary vote on Wednesday.

The Green Party also announced it would leave the coalition it had formed with Andersson’s Social Democrats.

The Greens said in a statement: “The current government will remain as an interim government until a new government is in place.”

Andersson told the Swedish parliament’s speaker that she would attempt to be reappointed prime minister as the leader of a “single party Social Democrat government,” Reuters reported.

She took over as the leader of her party after the resignation of Stefan Lofven, who had been the prime minister and the Social Democrat leader.

Andersson is the second woman to lead the Social Democrats, and had previously been the deputy director of the Swedish Tax Agency.

She had initially shored up her coalition by enacting a deal with the far left Left Party, but with a shaky political situation her ability to govern was always uncertain, according to media reports.

Lofven had managed to stay in power by satisfying both left and centrist parties who were not part of his coalition.

However, the budget vote was not successful due to the Center Party’s disapproval of Andersson’s deal with the formerly communist Left Party.

"We cannot support a budget from a government which is moving far to the left, which we think the incoming government is doing," Center Party leader Annie Loof said during a press conference.