GERMANY’S TWO big parties have finally agreed on a new government under Chancellor Angela Merkel, which is both good news and grounds for worry.

The announcement comes as a relief for many Germans weary of months of political uncertainty. It is welcome, too, for a European Union hoping for more robust support from Berlin. But it offers more reason for concern about the future of Western liberal democracy: That the German center-left and center-right were forced to renew a coalition that has weakened both of them underlines the growing strength of the political extremes and raises the specter that in Germany, as in other Western nations, the center ultimately may not hold.

Ms. Merkel, chancellor since 2005, has been a stable and effective leader for Germany and Europe and, in the past year, a welcome defender of liberal values, including human rights, in the age of President Trump. Germany’s economy has grown so strong that the new coalition will have a $55 billion budget surplus to redistribute on benefits for families, tax cuts and investments in infrastructure. That will be cheered by critics who for years have urged Berlin to spend more as a way of stimulating southern European economies and better balancing trade flows.

To win over the left-leaning Social Democrats (SPD), Ms. Merkel ended up handing the finance ministry as well as the foreign ministry to SPD appointees. With SPD leader Martin Schulz, a former president of the European Parliament, reported to be headed for the foreign ministry, Germany could become more amenable to proposals for strengthening E.U. institutions and the euro — to the delight of French President Emmanuel Macron.

The first shadow on this seemingly positive outcome is the possibility it will be rejected by the SPD’s members, who will vote on it in the next few weeks. Notably, the party’s youth wing is strenuously opposed to a new coalition; like leftist young people in Britain and the United States, young German progressives are dissatisfied with the compromises of the center.

The principal opposition to the coalition, meanwhile, will come from the right-wing Alternative for Germany (AfD) party, whose very name is a rebuff to Ms. Merkel’s insistent centrism. The coalition’s answer to the AfD’s strident opposition to immigration is a cap on refu­gee admissions of 180,000 to 220,000 a year — far below the approximately some 1 million who arrived in 2015. Having once championed the need for Europe to help people fleeing the carnage of Syria and Afghanistan, Ms. Merkel has bowed to the populist backlash against them, though her government will remain more welcoming to refugees than the Trump administration is.

The larger worry is that, with Ms. Merkel’s career widely perceived to be in its twilight, the strength of the centrist parties will be further eroded during another joint government. As it is, both received their lowest shares of the vote since the 1940s in last September’s election. If the new coalition falters, the AfD could be the leading beneficiary. In neighboring Austria, years of right-left coalitions finally led last year to the election of a new government including the far right. Ms. Merkel’s most important task will be to avoid leaving such a legacy.

Read more here: