BERLIN — After more than four months of tortuous negotiations, with her fate and Germany’s hanging in the balance, Chancellor Angela Merkel on Wednesday announced a deal for a new government.

But it was telling that Ms. Merkel, in power for 12 years, looked more weary than jubilant.

The new deal with the same old coalition partners — her conservative alliance and the left-leaning Social Democrats — is precisely the government that Germans had voted against in inconclusive elections last September. It leaves the far-right Alternative for Germany as the country’s leading opposition party. And it comes at a high cost for Ms. Merkel, the incredible shrinking chancellor, who had to relinquish key ministries.

But what is troubling for many Germans is not necessarily bad news for Europe, which for years has depended on stability in Berlin and has been waiting in limbo as Ms. Merkel stumbled toward a deal.

The new arrangement must still be approved by the Social Democrats’ rank and file. But if endorsed, the coalition may provide France’s new president, Emmanuel Macron, with the partner he has been looking for to help buck up the European Union and move it away from the austerity policies that were identified with Ms. Merkel’s old team and often blamed for stifling growth.