BERLIN — After two months of talks, German parties announced a new governing coalition Wednesday that will pave the way for Olaf Scholz of the center-left Social Democrats to take over from Chancellor Angela Merkel after her 16 years in power.

The Social Democratic Party, which narrowly won September elections, is allying with two other parties: the climate-conscious Greens and the pro-business Free Democrats.

Scholz, 63, said the alliance, nicknamed the “traffic light” coalition for the party colors of the three factions, is ready to lead Germany.

“The traffic light is on,” he said in a joint news conference with other party leaders.

For both Germany and wider Europe — where Merkel had taken on the role of a de facto leader — it marks the end of an era with Germany often at the center stage of policymaking.

But few expect drastic departures in policy from a government under Scholz, who served as finance minister in Merkel’s outgoing cabinet. Merkel has tried to position Germany as a bridge between the West and other nations, including Russia, balancing the trade interests of Europe’s largest economy with concerns such as human rights.

Merkel, who had decided not to run in September’s elections, will retire. Her center-right Christian Democrats will head into the opposition after posting their worst election results since the party was founded just after World War II.

A 177-page coalition agreement outlined plans by the Scholz government to increase the minimum wage, obtain 80 percent of the country’s electricity from renewables by 2030 and legalize cannabis.

“It’s evolution, not revolution,” Jürgen Falter, a politics professor at the University of Mainz, said of the coalition agreement.

Scholz will formally become chancellor when he is voted in by the Bundestag, Germany’s parliament, which is expected to happen next month. The coalition deal also has to be formally voted on by the parties.

He will take over the reins of a country being ravaged by a new wave of coronavirus infections, with Germany hitting record numbers of cases in recent weeks. Underscoring the depth of the crisis, Scholz began his speech Wednesday by addressing the health issues.

“The situation is bleak,” Scholz said, as he outlined how the new government would require that employees be vaccinated, show a negative test or have recovered from the virus. “The coronavirus is still not vanquished — unfortunately,” he said.

As finance minister during the pandemic, Scholz built a reputation as a steady hand, but he will also face broader challenges, including a migration crisis on the European Union’s borders with Belarus.

Scholz said partnerships with France and the United States would remain a cornerstone of German foreign policy.

The crises facing Europe are “becoming more difficult,” said Annalena Baerbock, who ran as the chancellor candidate for the Greens and is expected to become foreign minister.

She cited the recent crush of migrants on E.U. borders as Belarus’s leader, Alexander Lukashenko, opened routes for people from the Middle East and elsewhere in retaliation for E.U. sanctions.

“Therefore we have together agreed to return to an active European foreign policy, that focuses on the strength of diplomacy and dialogue and relies on a value and human rights-led diplomacy,” Baerbock said.

There is also the task of steering a three-way coalition made up of parties with different ideologies and aims. Scholz’s coalition is not the most natural of alliances.

The Social Democrats’ aims of strengthening the welfare state and the environmental policies of the Greens have not sat easily with the Free Democrats and their aversion to tax hikes.

Christian Lindner, leader of the Free Democrats, said talks were hard at times and the parties did not hide their differences.

But negotiators beat their promise to have a new coalition in place before Christmas and have tried to present a united front.

“We are united in our belief in progress and in the fact that politics can do good,” Scholz said. “We are united in our purpose to make the country better, take it forward and hold it together.”