The anti-establishment Five Star Movement (M5S) and the centre-left Democratic Party (PD), once enemies, agreed on Wednesday to form a coalition in order to avoid snap elections and save the country from economic despair.

One of the stumbling blocks had been the M5S’ insistence on Conte remaining as prime minister, but the PD eventually agreed on this condition.

“We must transform this crisis into an opportunity,” Conte said, insisting that Italy would once more become a key player in Europe after 14 months of a populist, anti-EU government.

He added that the new government would create “a fairer, more competitive, more united, more inclusive country”.

The former academic, who was chosen as a compromise prime minister last year, was handed a fresh mandate by the president and said he would take a few days for political consultations to ensure a parliamentary majority.

Conte has promised, once the coalition is confirmed, that the government will proceed quickly to agreeing a new budget for 2020.

He said the new coalition’s priorities would include improving infrastructure, boosting renewable energies and fighting tax evasion – but notably did not mention immigration, which has been Salvini’s political obsession.

The two parties still have a long way to go to agree on a policy platform and appoint ministers.

The M5S will also require its 100,000 members to back the deal via its online platform.

Many supporters will have reservations about a deal with a centre-left, mainstream party and a “yes” vote can’t be taken for granted.

Some centre-left politicians have also rejected a PD-M5S coalition, with MEP Carlo Calenda resigning from the leadership in protest.