FRANKFURT (Reuters) - U.S. buyout fund Cerberus [CBS.UL] has taken a 3 percent stake in Deutsche Bank <DBKGn.DE>, Germany's flagship lender said on Wednesday, making the fund one of its largest shareholders.

The private equity investor also built a 5 percent stake in Germany's second-largest listed bank, Commerzbank <CBKG.DE>, in July.

Cerberus's combined purchases in Germany's top two lenders, valued at 1.7 billion euros ($2.0 billion), are adding fuel to speculation of a merger between the two.

But senior officials from both banks say privately that their restructuring efforts have some way to go before they would consider any tie-ups.

Both lenders are carrying out major streamlining of their operations to reduce headcount, modernize IT and focus on their home markets and retail operations in an effort to post sustainable profits.

Commerzbank received a government bailout in the financial crisis, while Deutsche Bank is bouncing back from the brink of collapse last year.

"We have a constructive view of European fundamentals and believe Germany is a highly attractive place to invest, in particular," a Cerberus spokesman said, adding it saw long-term opportunities in retail and corporate banking due to Germany’s robust economy and high savings rate.

Cerberus is now the fourth-largest shareholder in Deutsche Bank after China's HNA group, Qatar and money manager Blackrock <BLK.N>. It is the second-largest investor in Commerzbank after the German government.

"This has fueled the fantasy of a merger between Deutsche Bank and Commerzbank," said a trader. "I can understand this speculation because Cerberus wouldn't buy into German banks without reason."

Shares in both banks recouped sharp losses earlier in the day to trade roughly flat by midafternoon.

Already in 2016, top executives of Deutsche Bank and Commerzbank have held talks on a potential combination, but shelved the project to complete their restructurings before taking steps towards any merger, a person close to the matter said at the time.

Christian Sewing, co-deputy CEO of Deutsche Bank, said at a banking conference in Frankfurt this week that Germany was "clearly overbanked" and predicted that "there will be a wave of domestic consolidation."

Some investors expect that Cerberus will leave a mark on Deutsche Bank. "Cerberus is an investor that makes clear demands and will also influence strategy," said Ingo Speich, a fund manager at Deutsche shareholder Union Investment.

Speculation that a new shareholder would emerge heightened after Deutsche Bank disclosed on Tuesday that Morgan Stanley <MS.N> had acquired a significant holding in voting rights linked to financial instruments.

It remains unclear, however, whether the Cerberus and Morgan Stanley disclosures are linked.

Morgan Stanley holds 6.86 percent of voting rights in the German lender, with the vast majority of those rights through instruments, Deutsche Bank said in a regulatory filing on Tuesday. Instruments include call options, rights of recall over securities lending agreements, equity swaps and put options.