BERLIN — Deutsche Bank, Germany’s biggest bank, and domestic rival Commerzbank have decided to open talks on a possible merger, the lenders said Sunday in an announcement that followed months of speculation about such a combination.

Commerzbank CBK, -1.50% said in a one-sentence statement that the banks “have agreed today to start discussions with an open outcome on a potential merger.”

Deutsche Bank DB, -1.10% DBK, -0.45% said its management board had decided to “review strategic options” and added that that there was no certainty of any transaction emerging. It said “in this context, we confirm that we are engaging in discussions with Commerzbank.”

A merger would combine two banks that had more than 133,000 full-time employees between them at the end of last year and have had troubles in recent years. Merger talk has been greeted by a degree of skepticism since both banks are busy overhauling their own businesses, raising the question of how they would integrate a new partner.

However, there has been persistent speculation over recent months that the two lenders, with apparent encouragement from the German government, would explore a possible combination.

Germany’s Finance Ministry has said that the country needs strong banks but hasn’t commented on reports that it favors and was even pushing for a merger. The Economy Ministry recently has talked of the importance of national and European “champions” that can compete on the world business scene, naming Deutsche Bank as an existing one.

Deutsche Bank has been engaged in a drawn-out restructuring and cost-cutting effort in an attempt to return to steady profits and put years of legal problems behind it. In 2018, it made its first full-year profit in three years, though it reported a loss for the fourth quarter.

Commerzbank, which received government aid during the financial crisis, also has been restructuring. The German government still has a stake of some 15% in the company.

In a message to Deutsche Bank employees, CEO Christian Sewing said the bank has “to assess how we want to play a part in shaping” consolidation of the German and European banking sector.

“What is also important to me is that we will only pursue options that make economic sense,” he wrote.

On the chances of a deal emerging, he wrote: “Experience has shown that there may be a lot of potential economic and technical factors that could hinder or prevent such a step.”

The talks “will take a while, because for us thoroughness comes before speed,” said Deutsche Bank’s head of communications, Joerg Eigendorf.

Deutsche Bank has a market value of some 16 billion euros ($18.1 billion), while Commerzbank weighs in at about 9 billion euros.

The prospect of a merger got a strong thumbs-down from the ver.di service workers’ union, which cited a potential risk to tens of thousands of jobs.

Union official Jan Duscheck argued that a merger would open up new risks and problems without resolving the old ones — “without added value being visible from a possible merger for the companies themselves, for consumers, for the economy, let alone for employees.”