For four months, Germany—that reputed pillar of stability in a tumultuous Europe—limped along without a government. The country’s elections in September not only failed to deliver a clear governing majority for German Chancellor Angela Merkel’s conservatives, but it also brought unprecedented gains for the populist party Alternative für Deutschland party (AfD), marking the first time a far-right party would enter German’s national parliament in nearly six decades. The Social Democrats, who had served as the coalition partner of Chancellor Angela Merkel’s party for nearly a decade, refused to join her again, preferring instead to lead the opposition. But no one would form a government with the AfD either. The result: Deadlock.

Until Wednesday.

Which is when a 23-hour marathon negotiating session resulted in a compromise that would return the very same kind of grand coalition that has governed the country for eight years. Faced with the prospect of new elections (which polls projected would earn them yet another crushing defeat), the Social Democrats decided they could work with Merkel after all. And after months of uncertainty, the Germans ended up roughly where they started.

Yet there were some differences. The Social Democrats, despite their comparatively poor showing in the September election, walked away from the coalition negotiations with some notable wins, including control of the coveted foreign, finance, and labor ministries. Merkel’s Christian Democrats (CDU) also lost their hold on the interior ministry to a more-conservative politician from their sister party, the CSU. “The CDU, even though they have the largest share of the votes, doesn’t have any of the key ministries,” Marcel Dirsus, a political scientist at the University of Kiel, told me, noting that “Merkel paid a very steep price” to get this government.

The ministerial shake-ups have been widely regarded as concessions by Merkel made to ensure the success of the negotiations and stave off the possibility of fresh elections. And while some of the changes will have notable implications for Germany (such as the move to give Social Democrats control of the labor ministry, which will allow it to push for its own traditional left-wing policies, such as on employees’ rights), in other ways the changes promise much of the same. In the case of the move to reportedly replace as finance minister CDU lawmaker Wolfgang Schäuble with the Social Democrats’ Olaf Scholz, Dirsus said, “this is a guy who is not a radical—he’s a centrist, and he’s quite pragmatic. So just because the [Social Democrats (SPD) have] the finance ministry doesn’t mean that Germany is going to radically change its course when it comes to eurozone integration … Personalities like Olaf Scholz will make a drastic change less likely.”

While more than half of Germans were found to be in favor of fresh elections if coalition talks failed, it’s not an option either Merkel’s conservatives or the Social Democrats would benefit from. In fact, a recent survey by the German newspaper Bild revealed that if elections were held today, the grand coalition would lose support, with Merkel’s conservatives dropping by three points and the Social Democrats dropping by half a point. Such an outcome would put the SPD just two points ahead of the populist far-right AfD, which under this coalition deal makes them the largest opposition party in the country. It’s a calculus that Dirsus says gives the SPD leaders little choice but to accept the deal. “A lot of the people who just got elected simply don’t want to go through another election again,” he said. “It’s tiring, it’s expensive.”

Unfortunately for them, they may not have a choice. Before the grand coalition can become a reality, it must first be approved by the SPD’s more than 460,000 members, who will have the final say on the coalition agreement when they vote by mail in the coming weeks. How that vote will go is anyone’s guess—just a narrow majority of the party’s delegates backed entering into formal coalition talks, despite SPD leadership’s strong endorsement in favor of doing so. Kevin Kühnert, the leader of party’s youth wing, signaled that some of the party’s younger members are adamant in their opposition to the Social Democrats entering another grand coalition. “#NoGroko does not just mean rejecting a coalition agreement,” he tweeted in response to the coalition deal. “#NoGroko also means the rejection of the political style that is being performed today.” If, however, the party votes in favor of accepting the deal, Germany could have a new government by Easter.

But for now, party leaders involved in the deal appear to be optimistic. “Tired. But satisfied,” is how the Social Democrats’ leaders summed up their reaction in a WhatsApp message to its members confirming that a deal had been reached. Alexander Dobrindt, a CSU lawmaker, similarly hailed the agreement, noting that  “it’s about time we had a prospect of a government in Germany. So it’s a good day.”