Keeping one of Europe's last centre-left governments in power is seen as a major victory for the 61-year-old Löfven, a former welder and union leader.
And the feat is even more exceptional given Sweden's splintered political landscape after the September 9th legislative elections, when the left wing scored just one more seat in parliament than the right and the anti-immigration far-right came in third, looking set to be kingmakers.
Going into the election, Löfven appeared more isolated than ever, roasted on the right for leaving the country's door open to asylum seekers and lambasted by the left for later slamming it shut.
But the rightwing opposition failed in repeated efforts to form a government that didn't rely on the support of the far-right nationalist Sweden Democrats.
Löfven, with a reputation as a talented tactician and negotiator, emerged the winner after he cemented a deal with two centre-right parties, the Centre and the Liberals, to support his minority coalition government comprising of the Social Democrats and the Greens in parliament.
The Centre and the Liberals had until now been part of the four-party, centre-right Alliance that challenged Löfven in the election.
“Löfven has reached his strategic goals: to remain in power and to split up the non-socialist Alliance opposition,” political scientist Olof Petersson told AFP.
But that victory may come at a price, namely, the risk of a backlash in the next election in 2022, analysts said.
To secure his collaboration with the centre-right, Löfven signed a 16-page policy document that reflects large parts of the rightwing's election platform – and which will undoubtedly alienate part of his party base.
“In exchange for the position of prime minister, the Social Democrats are paying the price with liberal reforms,” Sweden's paper of reference, the liberal Dagens Nyheter, wrote.
Sometimes called a “rightwing socialist”, Löfven will now have a hard time improving his image among his old socialist friends.
Löfven has already lost points in his own camp by shutting Sweden's borders to immigrants at the end of 2015, after welcoming more than 240,000 asylum seekers since 2014.
On November 24th, 2015, he announced Sweden was aligning its asylum policy with the European Union's minimal levels and cracking down on family reunifications.
“It pains me to say that Sweden can no longer take in asylum-seekers at the same high level… Sweden needs some breathing room,” Löfven told a news conference, his Green Party deputy prime minister Åsa Romson at his side, with tears in her eyes.
Just two months earlier he had said: “My Europe doesn't build walls, my Europe takes in refugees.”
“Even Angela Merkel in Germany had to do a U-turn on immigration. But no leader in Europe did as brutal an about-face as Stefan Löfven,” wrote Dagens Nyheter in May.
Löfven's detractors had said his stance on immigration and integration was “naive” and “irresponsible”.
To counter that image, he took a hard line during the election campaign last autumn, repeatedly stressing that new arrivals in Sweden have both “rights and responsibilities”.
Born in Stockholm in 1957, poverty forced his mother to give him up when he was ten months old to a foster family in Sollefteå, 500 kilometres north of the capital, where his foster father was a factory worker.
He became a welder and spent 15 years working in a defence factory, joining the union in the early 1980s and ending up as head of the metal workers' union IF Metall from 2006 to 2012.
IN PICTURES: 15 times Stefan Löfven looked incredibly Swedish
Seen by some as a poor orator who lacks charisma, he is nevertheless popular with many Swedes who see him as genuine.
A Skop poll last year showed a majority of Swedes would rather break bread with him than with the leader of the opposition, conservative Moderate Party leader Ulf Kristersson.
After governing Sweden through a long period of growth and favourable economic conditions from 2014 to 2018, Löfven is now likely to have to contend with a downturn in the domestic and international economy, as forecast by experts.
Article by AFP's Gaël Branchereau, edited by The Local