BRATISLAVA, Slovakia — Slovakia’s prime minister announced on Wednesday that he was ready to resign as a way out of the political crisis triggered by the slayings of an investigative journalist and his fiancee.

Robert Fico’s surprise move was meant to keep the current three-party coalition in power and avoid the possibility of early elections.

“The early elections would be almost certainly accompanied by chaos and instability,” Fico said.

His government coalition came to power after 2016 general elections. The next regular ballot is planned for 2020.

Fico said he was ready to resign if the next prime minister is from his left-wing Smer-Social Democracy party and to present his or her name Thursday.

Fico agreed on the plan with the leaders of the other two coalition partners, the Most-Hid party representing ethnic Hungarians and the ultranationalist Slovak National Party.

The deal needs approval from President Andrej Kiska, Fico’s rival. According to the Slovak Constitution, it is the president who picks the prime minister.

If the prime minister steps down, it means the end of the entire government.

Kiska already proposed either major changes in the government or an early election as ways to resolve the crisis, suggestions Fico initially dismissed.

It was not immediately clear if Kiska was ready to agree with Fico’s new initiative.

It came after tens of thousands of Slovaks joined in anti-government protests across the country last week to demand the government’s resignation and a thorough investigation of the shooting deaths of Jan Kuciak and Martina Kusnirova.

They were the biggest protests in Slovakia since the 1989 anti-communist Velvet Revolution. Kuciak was writing about ties between the Italian mafia and people close to Fico.

More anti-government protests are scheduled for Friday despite’s Fico’s move, organizers immediately said.

Earlier this week, the crisis deepened after the Most-Hid coalition party called for resolving the situation by holding early elections.

Most-Hid chairman Bela Bugar welcomed Fico’s decision, saying it could “calm down the situation.”

He said the newly created government would mean “the continuity in what we started two years ago.”

Fico’s announcement came amid a poll suggesting a drop in the popularity of his party.