German Chancellor Angela Merkel will form her fourth government after the opposition parties of the Social Democrats (SPD) have voted for a new big coalition.
The vote by 464,000 constituents ends five months of political deadlock since the September election.
The SPD was divided between the leadership of the party, which supported the coalition, and the radical youth wing, which did not.
Mrs. Merkel, who has been in power for twelve years, congratulated the SPD.  On the Twitter feed of her party. she said she "looks forward to working together again for the benefit of our country".
SPD voters voted in favor of the coalition with 66%. Party leadership had been concerned that younger voters might veto a deal. Voting counting continued through the night at the party headquarters in Berlin.
Interim SPD leader Olaf Scholz stated: "Now we have clarity." The SPD will enter the next government. "
The chancellor is now faced with a series of challenges, including strong opposition from the nationalist alternative to Germany (AfD).
The anti-immigrant party joined the federal parliament for the first time in September with a little more than 12% of the votes and is now the largest opposition group.
The SPD suffered the worst election result ever and many accused their coalition of the Christian Democrats of Mrs. Merkel (CDU / CSU) for that poor performance.
Mrs. Merkel, who also performed poorly, lost 65 seats, had tried and failed to form an alliance with Liberal Free Democrats (FDP) and the Greens.
She was forced to pay a higher price for continuing the existing coalition – the new finance minister will be a social democrat.
The SPD will now decide who will fulfill the six ministerial roles to which he is entitled before the expected arrival of Mrs. Merkel's election by parliament on 14 March.
Martin Schulz, the former high-profile SPD chairman, had put himself forward as a potential foreign minister, but dropped the plan because of internal quarrels about who should fulfill the function.
He also annoyed many party members by first excluding a coalition in the aftermath of the SPD's bad election that later only entered the talks.
The end of the uncertainty, including the possibility of new elections, will be greeted with relief in the institutions of the European Union, where Germany, the largest economy in Europe, has a big influence
Merkel lets her work be removed
Analysis by Jenny Hill, BBC News, Berlin
Germany has almost waited six months before. The new government is a continuation of the previous one – a coalition between the conservatives of Angela Merkel and the Social Democrats, or the SPD.
Mrs Merkel will undoubtedly be relieved. But this is not a glorious victory. The SPD – who had the last word on the coalition agreements – broke the decision to renew the alliance. Many members still resist and the internal schism has worsened the bad rating of the poor.
There is also a limited public enthusiasm for the union. Months of political bickering (remember that Mrs. Merkel tried – and failed – to form a coalition with the Green and FDP parties) has done little to inspire confidence in the established parties in Germany.
Angela Merkel, herself deeply damaged by the whole episode, has now cut her work if she wants to deliver the stability she has promised her country.