THE prime minister of Sweden will soon be forced to quit after losing a vote of confidence in parliament.

Stefan Lofven, the leader of the Social Democratic Party, will continue as caretaker prime minister until a new government can be formed that has the command of the Riksdagen.

Members of parliament voted 204-142 against Lofven, who has been prime minister since 2014, with three opting to abstain.

Tuesday's vote was mandatory after elections earlier this month delivered a hung parliament.

Neither the left-leaning bloc led by the Social Democrats nor the Moderates-led centre-right opposition managed to secure a majority in the 349-seat parliament after the September 9 vote.

Both have refused to co-operate with the anti-immigration Sweden Democrats.

The Social Democrats won 28.3% of the vote, the Moderate Party received 19.8% and the Sweden Democrats earned 17.5%.

The centre-left and centre-right blocs control 144 and 143 seats respectively, while the Sweden Democrats have 62 legislators in the assembly.

Andreas Norlen, a member of the Moderates who was elected on Monday as speaker, is charged with trying to find someone in parliament who may be able to command a majority and form a government.

He alone decides which of the party leaders can begin these talks.

Lofven remained optimistic he could form a governing coalition but stopped short of saying who with.

“I am available for talks,” he said after the vote.

The nationalist Sweden Democrats could potentially break the deadlock but the outgoing prime minister ruled out any agreement with them.

He explained: “Time after time, their connections to racist and Nazi organisations have been exposed”.

Ulf Kristersson, leader of the Moderates, is widely considered to be the front-runner to replace Lofven as prime minister.

If he does not form a new government, others may be invited to do so.

If four attempts to form a government fail to succeed, new elections could be triggered.