BERLIN — Olaf Scholz has managed what many in Germany had considered impossible: bringing the Social Democrats back from the dead.

The center-left Social Democratic Party, known as the SPD for its initials in German, is Germany’s oldest political party, It has also languished in the polls for years.

But in Sunday’s elections, the SPD pulled ahead, winning 26 percent of the vote, according to preliminary numbers. The center-right Christian Democratic Union won 24 percent of the vote, the lowest mark for the party since its founding in 1945.

But Scholz still needs to forge a majority coalition if he is to replace the CDU’s Angela Merkel as chancellor as she retires after 16 years at the helm.

Scholz’s party was the junior partner to the CDU in Merkel’s outgoing government, the third time the SPD joined its traditional rival in a coalition. It’s a position the SPD took on reluctantly — but one that has enabled Scholz to raise his profile nationally.

As finance minister and vice chancellor in Merkel’s cabinet during the pandemic, Scholz, 63, built a reputation as having steady hands during a crisis. He oversaw the distribution of billions of euros in coronavirus relief and emergency aid to victims of the summer’s deadly flooding in western Germany.

He has been called the “Scholzomat” for his dry, verging on boring, political style. But that may have served him well with voters still attached to Merkel, who was hardly known for impassioned speeches. Despite being from a different party, he has positioned himself as her natural successor.

Preliminary numbers showed German Chancellor Angela Merkel's Christian Democrats came in second to the center-left Social Democrats on Sept. 26. (Reuters)

“Obviously Merkel has left a huge impact on the political culture of Germany through her governing style,” said Frank Stauss, a political communications consultant who has worked with the SPD in the past. Scholz is not a “Merkel clone,” Stauss added, but he has a similar enough political style to attract voters who might be looking for more of the same.

Scholz, a lifelong Social Democrat, was born in Osnabrück in the northwestern German state of Lower Saxony and raised in the wealthy city-state of Hamburg on Germany’s northern coast, where he also served as mayor. Alternating between state and national politics, he has served in the parliament, or Bundestag, and as minister of labor and social affairs in Merkel’s first cabinet.

His political career has been buffeted by scandals. While mayor of Hamburg, he faced criticism for his handling of the Group of 20 summit in 2017, as the event descended into widespread violence between protesters and police.

A parliamentary inquiry by opposition lawmakers earlier this year called him out for a lack of oversight after the financial technology company Wirecard unraveled on his watch in Germany’s biggest postwar fraud scandal. He has rebuffed accusations that he bears any political responsibility.

Scholz has also been questioned in an inquiry into whether he acted to influence tax authorities on behalf of a Hamburg bank at the center of the “cum-ex” fraud scandal, which deprived the German state of billions of euros in revenue. He has denied any wrongdoing, and no concrete evidence has emerged against him.

In the latest twist, Scholz was forced to return to Berlin from the campaign trail last week to answer questions in the parliamentary finance committee. The inquiry was called after the public prosecutor ordered searches of the Finance Ministry as part of an investigation into allegations of obstruction of justice at its anti-money laundering unit. SPD lawmakers implied that the timing was suspect, as Scholz’s party had taken a lead in the polls.

But he has emerged relatively unscathed. “It has not had a major impact,” said Peter Matuschek, an analyst with polling agency Forsa.

What really boosted Scholz and the SPD has been the stumbling campaigns of his rivals.

To the right of his party, Scholz may have been able to win over those who had previously opted for the more conservative CDU because of Merkel. The SPD’s campaign issues included raising the minimum wage and taxes on the rich.

Unlike the Green Party, which wants to phase out coal by 2030, the SPD wants to stick to the existing target date of 2038. The SPD’s traditional support base had included many of Germany’s miners and blue-collar workers before much of that electorate fell away to other parties.

Scholz has consistently performed well in surveys that ask Germans the theoretical question of who they would vote for if they could directly elect the chancellor. As the elections neared, that transferred to a bump for his party.

The soft-spoken finance minister had expressed a quiet confidence that he would succeed, even in the early days of his campaign, when he was all but counted out. “I want to win,” Scholz told reporters as he announced his candidacy.