The centre-left Social Democrats (SPD) have gained a slim victory in Germany’s federal elections, beating the outgoing Chancellor Angela Merkel’s Christian Democratic Union (CDU).

According to preliminary results, the SPD has secured 25.7% of the vote, while the ruling centre-right CDU/CSU bloc gained 24.1%.

The Greens came in third with 14.8% of the ballot, the largest vote share in their history. Meanwhile, the classical-liberal Free Democratic Party (FDP) will likely win around 11.5%.

It now remains to be seen which combination of parties will form a governing coalition, a process that could last until Christmas.

SPD leader Olaf Scholz has now said that his party has a clear mandate to rule, but the ruling union will also now attempt to form a coalition.

It was expected that the conservative CDU-CSU union would achieve a higher vote share given its outgoing Chancellor’s popularity after 16 years in power.

Regional CDU organiser Christophe Lehmann told Sky News today that the party’s problems were due to their candidate for the Chancellorship. He said: “We had to drive against the wind… Because many people didn’t understand why we picked [Armin] Laschet. Voters were not convinced.”

Laschet sparked backlash in July after he was recorded laughing while the president delivered a speech in the wake of floods that killed 196 people in Germany.

The FDP and Greens together hold a quarter of the vote and could therefore carry either of the main parties over the threshold to form a government.

While both are more popular with voters under 30, they hold opposing views on a range of critical policy issues.

Greens leader Annalena Baerbock wants to loosen Germany’s rules that currently prevent a large increase in public debt, while FDP leader Christian Lindner would likely demand tax cuts and limits on borrowing and spending.

This marks the first time Germany will face a three-way coalition.

The right-wing nationalist AfD’s national vote share seems to have dipped nationally but is predicted to be the largest party in Saxony and Thuringia.

The democratic socialist party Die Linke fell below the 5% threshold required to get into parliament but survived because it secured three direct mandates.

German voters can make two decisions on their ballot. On the left side of the ballot, they can directly vote for a member of parliament in their constituency. Every candidate who is directly elected receives a seat in the Bundestag (German parliament).

On the right side of the ballot, Germans can vote for a political party, which will be proportionally represented in the Bundestag as long as they receive at least 5 per cent of the party votes in a given state.