MPs voted again to elect Swedish Social Democratic Party leader Magdalena Andersson on Monday

Sweden’s first female prime minister has been reappointed to the top job after political turmoil forced her to resign within hours of taking the post last week.

MPs backed Social Democratic Party leader Magdalena Andersson by a narrow margin in a new vote on Monday.

She will attempt to lead a one-party government until an election in September next year.

She stood down as prime minister last Thursday after her coalition collapsed.

Just hours earlier, Ms. Andersson had been elected as Sweden’s first female prime minister by a single vote in parliament.

But the 54-year-old economist’s plan for forming a new coalition government with the Green Party was thrown into disarray when her budget proposal failed to pass.

Sweden’s first female PM resigns hours after the appointment

Instead, parliament voted for a budget drawn up by a group of opposition parties, including the far-right Sweden Democrats.

The Green Party said it would not accept a budget drafted by the far-right and walked away from the government, leading to its demise.

By convention, the prime minister in Sweden is expected to resign if a coalition party leaves the government.

In Monday’s vote, 101 of the Riksdag’s 349 members voted yes, 75 abstained and 173 voted no, according to Swedish broadcaster SVT.

To be appointed prime minister under Sweden’s political system, a candidate only needs to avoid a majority voting against them.

Ms. Andersson was applauded by some MPs in parliament when the result of the vote was confirmed.

Once formed, Ms. Andersson’s new government will remain in place until general elections, which are set to take place in September next year.

A former junior swimming champion from the university city of Uppsala, she began her political career in 1996 as political adviser to then-Prime Minister Goran Persson.

She has spent the past seven years as finance minister before becoming leader of the Social Democrats at the start of November.

She replaced Stefan Lofven, who resigned as prime minister after seven years in power.

Until Ms. Andersson took over, Mr. Lofven had remained prime minister of a caretaker government after being ousted in an unprecedented vote of no confidence in June.