Italy's populist Five Star Movement (M5S) and the center-left Democratic Party (PD) have put aside their traditional differences to form a new government and prevent new elections.
Five Star (M5S) said the coalition would be led by Prime Minister Giuseppe Conte, who had resigned following the collapse of the coalition government between M5S and the far-right Lega earlier this month.
"Today we told the president of the republic that there is a political agreement with the Democratic Party that Giuseppe Conte may be again given a mandate as prime minister," M5S leader Luigi Di Maio said.
PD leader Nicola Zingaretti said the two sides had decided to find common ground for the sake of the country's stability. "We love Italy and we consider it worthwhile to try this experience," Zingaretti told reporters following the talks.
Speaking shortly afterwards, Di Maio said: "We made commitments to the Italians...and come what may we want to fulfil them."
The M5S leader also said he had turned down an offer from the Lega, headed by Interior Minister Matteo Salvini, to become prime minister himself in return for renewing their alliance.
PD and M5S still need to agree a policy platform and a team of ministers.
Had the PD and M5S been unable to form a solid majority, the president would likely have called an early election for November.