BERLIN (AP) — Germany’s voters have delivered their verdict. Now it’s up to party leaders to thrash out who will succeed Chancellor Angela Merkel after 16 years in office and with what political priorities.

The shape of Germany’s new Bundestag, or lower house of parliament, is now clear. But there are majorities for three more or less plausible new coalition governments, and it could take weeks or months to put a new administration in place. Here’s a look at how the process works.

WHAT HAPPENS NEXT?

The first-placed party typically leads German governments, but that isn’t always the case. It can end up in opposition if other parties form a coalition without it. That happened in 1976 and 1980, when then-Chancellor Helmut Schmidt stayed in office although his party finished second.

There is no referee for the process of forming a new government, and no set time limit. Parties hold exploratory talks to determine who they have most common ground with, and one combination of parties then moves on to formal coalition talks.

Those negotiations typically produce a detailed coalition agreement setting out the new government’s plans. That will typically need approval at least from congresses of the parties involved. The center-left Social Democrats, who emerged from Sunday’s election as the strongest party, held ballots of their entire membership in 2013 and 2018 to sign off on agreements to join Merkel’s center-right Union bloc as its junior partner in government.

Once a coalition is ready, Germany’s president nominates to the Bundestag a candidate for chancellor, who needs a majority of all members to be elected.

If two attempts to elect a chancellor with a majority fail, the constitution allows for the president to appoint the candidate who wins the most votes in a third vote as chancellor or to dissolve the Bundestag and hold a new national election. That has never yet happened.

WHEN WILL MERKEL STEP DOWN?

Merkel and her outgoing government will remain in office in a caretaker capacity until the Bundestag elects her successor.

The outgoing coalition holds the record for the longest time taken to form a government, after an attempt to form an alternative alliance collapsed. The Bundestag elected Merkel for her fourth term on March 14, 2018 — nearly six months after German voters had their say on Sept. 24, 2017.

One side-effect of a very long coalition-building process might be to add another aspect to Merkel’s legacy. Among democratic Germany’s post-World War II leaders, she has served longer than all but Helmut Kohl, who led the country to reunification during his 1982-98 tenure. She would overtake even him if she is still in office on Dec. 17.

WHAT PARTIES ARE INVOLVED?

Four parties are potentially in play to form the new government. The outcome will almost certainly be a coalition that has a majority of the seats in parliament. Germany has no tradition of minority governments, which are generally viewed as unstable and undesirable.

The Social Democrats of outgoing finance minister and Vice Chancellor Olaf Scholz are the biggest party, but even they are far short of a majority with 206 of the 735 seats in parliament.

They want to build a coalition with the environmentalist Greens and the business-friendly Free Democrats. The Union bloc under Merkel’s would-be successor, Armin Laschet, could also form a government with those two parties. The former is known in Germany as a “traffic light” coalition, after the parties’ colors of red, green and yellow; a Union-led alliance is labeled a “Jamaica” coalition because the party colors of black, green and yellow reflect that country’s flag. Both have been tried successfully in German state governments, but not at national level.

Agreeing on either may not be easy because the Greens in recent decades have tended to ally themselves with the Social Democrats, and the Free Democrats with the Union. The two parties have different priorities on fighting climate change, which the Greens want to put at the center of the new government’s agenda, and on how to handle the economy as it recovers from the pandemic.

The Free Democrats and Union oppose raising taxes and loosening Germany’s tight rules on running up public debt. The Social Democrats and Greens want to raise taxes for top earners and increase the minimum wage.

In Europe, the Union and Free Democrats have tended to take a stricter line on financial aid to struggling countries. But either alliance is unlikely to be troubled by huge foreign policy differences, though the Greens favor a tougher line toward China and Russia, and oppose the new Nord Stream 2 pipeline bringing Russian gas to Germany.

There is one alternative to a “traffic light” or “Jamaica” coalition — a repeat of the outgoing “grand coalition” of the Union and Social Democrats, but this time under the latter’s leadership. This combination of rivals has run Germany for 12 years of Merkel’s 16-year tenure and has often been marred by squabbling. There is little appetite for it.