Luigi Di Maio has resigned as leader of the Five Star Movement (M5S), part of Italy’s ruling coalition, as he seeks to calm the turmoil within the party threatening the government’s survival.

Di Maio, 33, had been under pressure to step down after losing more than 20 MPs, who either left or were kicked out, after the party formed an alliance with the centre-left Democratic party (PD) in September. Di Maio will retain his position as foreign minister.

Vito Crimi, a member of the Italian senate, is to temporarily take over as leader until a party conference in March.

“It is time to rebuild, an era closes today,” Di Maio said. “I worked to grow the movement and protect it from profiteers and traps along the way, even by making some tough and incomprehensible choices.”

M5S has lost half of its supporters since scoring the largest share of the vote in national elections in 2018. It has performed dismally in local elections and is expected to be badly defeated in regional elections in both Emilia-Romagna and Calabria on Sunday.

“His resignation is more of a move to try and contain the potential turmoil of the party that could erupt on Monday,” said Wolfango Piccoli, the co-president of the London-based research company Teneo.

“It’s some sort of internal party management, but the reality is that there are more question marks about the party … its sense of mission has been somewhat betrayed, it needs to reinvent itself.”

Since mid-December, M5S has lost the education minister, Lorenzo Fioramonti – who resigned from both the party and the role in the cabinet – and three senators, who defected to Matteo Salvini’s far-right League. Another senator was ejected for voting against the 2020 budget and two left on Tuesday.

If Di Maio’s resignation succeeds in containing the turmoil, at least in the short-term, then the risk of the coalition collapsing “is maybe lower than it was yesterday”, Piccoli said.

“It will obviously depend a lot on what happens to PD in the Emilia-Romagna elections, but as far as M5S is concerned we see his resignation as something positive for the continuation of the coalition.”

A coalition led by the League is threatening to end 70 years of leftwing rule in Emilia-Romagna on Sunday, with polls before the black-out period began showing its candidate, Lucia Borgonzoni, neck-and-neck with the PD’s incumbent president, Stefano Bonacini. A triumph for the League would be a coup for Salvini, who is plotting a return to power after collapsing his party’s coalition with M5S last summer in a bid to force snap elections. Meanwhile, a loss for PD could be detrimental to the fragile national coalition.

Di Maio, who worked as a football stadium steward before joining M5S in his early 20s, was elected leader in 2017 as the party sought to broaden its appeal beyond the bombastic, anti-establishment origins laid down by its founder, the comedian Beppe Grillo.

M5S enjoyed immense popularity in the run-up to the 2018 elections, which culminated in it winning 33% of the vote, but after its failed alliance with the League and subsequent one with PD, the party now polls at about 16%.