A political impasse that kept Germany in limbo for more than five months ended Sunday as the center-left Social Democrats voted to join a government led by Chancellor Angela Merkel's conservatives.
The vote of the party's 464,000 rank-and-file members revives a so-called "grand coalition" - the relatively drama-free but entirely loveless marriage of convenience between Germany's traditionally dominant parties that governed for the previous four years.
More importantly, it averts a detour into what would have been uncharted political territory for the country, with Merkel facing an unpalatable choice between governing without a parliamentary majority or facing new elections following an inconclusive September vote.
But even with the question of who will run Germany out of the way, the prolonged deadlock has left Merkel weakened. More so than at any other point in her tenure, questions are swirling over who will follow her as leader of Europe's most populous nation.
Merkel will also have to reassert herself on the international stage, an arena where she has long held sway but from which she has largely been absent in recent months as domestic troubles consumed her attention.
She is now expected to move quickly to try to cement a legacy, especially in Europe, where she and French President Emmanuel Macron have their eyes on ambitious plans for reform.
The relief at the vote result showed in a flurry of tweets from members of her inner circle in the Christian Democratic Union (CDU).
"Let's get to work! Germany and Europe," tweeted Peter Altmaier, perhaps her closest confidante, who added a smiling sun emoji for good measure.
Merkel's former and future partners, the Social Democrats (SPD), were more restrained, with few celebrating a decision that nearly tore the party apart.
Sunday's results only partially reflected the SPD's deep ambivalence: 66 percent of members endorsed the new coalition, with 34 percent rejecting it. While that's a substantial majority, it's well below the 76 percent who endorsed the last deal in 2013. And even party leaders who opted for "yes" this time said they did so reluctantly.
"Others dodged their responsibility. We didn't," deputy SPD leader Ralf Stegner told German broadcasters, reflecting the grim, do-your-duty argument that had coursed through the "yes" camp.
Neither major party originally wanted a government that has been dubbed by critics and the press a "coalition of losers." Both of Germany's traditional political heavyweights suffered historically bad results in the September vote, with their combined vote share at 53 percent - barely a majority - as smaller parties surged.
After the election, Merkel had first tried to forge a three-way deal with the pro-business Free Democrats and the environmentalist Greens. But when negotiations fell apart, she had to convince the SPD to reverse its earlier pledge to stay out of government.
The party, Germany's oldest, has been Merkel's junior coalition partner for two of her three terms. The arrangement has allowed the party to achieve critical policy successes, including enacting a minimum wage. But it has been politically disastrous.
The SPD won just 20 percent of the vote in September, half its support from two decades ago. Recent polls show it sliding down to 15 percent, below the far-right Alternative for Germany (AfD).
The question of whether to team up with Merkel once more split the SPD, and cost the party its leader, Martin Schulz, who was forced to resign after less than a year in office following a series of embarrassing flip-flops.
The party's youth wing, in particular, railed against the idea of another grand coalition. Young activists campaigned nationwide in recent weeks for members to reject the deal and take the party into opposition.
But party leaders argued that as costly as it would be to renew vows with Merkel, a "no" vote would have been worse: The party would likely have had to face voters in another election, and could have expected even poorer results than in September.
After the vote, youth wing leader Kevin Kuehnert said he was disappointed but would continue to drive the party toward a less cozy relationship with Merkel's conservatives.
"The SPD needs to be more of what it was in the last weeks, and less of what it was in the last years," he wrote on Twitter.
Merkel's CDU has been far less divided than the SPD but has still shown signs of strain after a dozen years in power.
Members of the party's right wing were particularly aggrieved by the outcome of coalition talks, which ended with the SPD taking control of key ministries, including foreign and finance. Some openly criticized Merkel for giving away too much - a rare breach in a party accustomed to strictly enforced discipline.
Focus also turned for the first time to the question of who will follow Merkel in office. She has long resisted grooming a successor. But in recent days Merkel has appointed several rising party stars to key positions, setting off an unofficial campaign to sort out who's next in the chancellery.
Annegret Kramp-Karrenbauer, the 55-year-old longtime leader of the west German state of Saarland, is considered Merkel's preferred heir, though she has not said so publicly. Kramp-Karrenbauer, nicknamed AKK in the German media, was appointed general secretary of the CDU, a position Merkel herself held on her rise to the top.
Another contender, 37-year-old Jens Spahn, will be health minister. Spahn has argued for the country to pivot right after years of centrism under Merkel, and has been especially critical of her decision to welcome more than a million refugees in 2015 and 2016.
With the approval of the coalition on Sunday, Merkel will have the chance to serve another four-year term. But the SPD could opt out after two years, and commentators have speculated that Merkel could step down early.
For the meantime, her position is secure. Merkel is expected to meet in the coming weeks with Macron, and the two have said they want to agree this month on plans to more tightly bind together the euro zone.
The SPD has expressed enthusiasm for Macron's proposals. Merkel, whose party has long been reluctant to go along with policies that could increase German liability for its neighbors' finances, has lately shown greater flexibility. In January, she said she would use her fourth term, in part, to achieve a "new awakening for Europe."
Luisa Beck contributed to this report.