Sweden’s parliament voted on Friday to give Social Democrat leader Stefan Lofven a second term in office, ending more than four months of deadlock after an inconclusive election, Reuters reports.

Lofven agreed an historic deal with the Centre, Liberal and Green parties last week, bringing together parties from the centre-right and centre-left in order to prevent the anti-immigration Sweden Democrats from having a voice in policy.

The deal will see Lofven, a former welder and union leader, cut taxes and deregulate the labour and property rental market, a sharp shift to the right that is likely to alienate many of the Social Democrat’s traditional supporters.

Lofven was supported by 115 law makers while 153 voted against him and 77 abstained. According to Swedish law, the nominee becomes prime minister as long as a majority of parliament does not vote against him or her.

September’s election delivered a hung parliament with neither major bloc able to rule without the support of the anti-immigration Sweden Democrats, a party with roots in the white-supremacist fringe and who hold the balance of power.