“This will strengthen their relationship,” Mr. Zhang said in a telephone interview.

The deal coincides with efforts by automakers across China to maneuver for control of joint ventures. President Xi Jinping announced last year, under pressure from the United States, that in the coming years he would eliminate a requirement that foreign automakers assemble cars in China only through 50-50 joint ventures with local automakers. The German automaker BMW has already disclosed plans to increase its stake in its joint venture with Brilliance Auto of China when the current regulations are erased.

Beijing Auto was able to acquire Daimler shares on the open market while they are relatively cheap. The stock has lost more than a third of its value since the beginning of 2018, and it has been under pressure since Daimler issued a profit warning this month. The shares rose almost 5 percent in trading in Frankfurt on Tuesday.

Based on Daimler’s current market capitalization, a 5 percent stake would be valued at roughly $2.8 billion.

Daimler said it welcomed the investment.

“The Chinese market is and remains a crucial pillar of our success, not only for sales, but also for our product development and production,” Ola Källenius, Daimler’s chief executive, said in a statement.

Daimler’s China sales rose 5 percent last year compared with 2017, but a shadow hangs over the broader Chinese market. Car sales in the country have plunged in recent months as consumers show signs of nervousness over slowing economic growth. New emissions rules have also been a factor.

Daimler warned on July 12 that it would report a pretax loss of 1.6 billion euros, or $1.8 billion, for the second quarter. The company blamed the poor results on slumping sales and the cost of investigations into whether it had sold diesel cars that evaded emissions regulations. Most carmakers are under pressure because sales are slumping in every major market, including China.

Germany’s makers of luxury cars face a particularly serious challenge in China from Toyota and its luxury brand, Lexus. After many years of paying limited attention to the Chinese market, Toyota decided two years ago to expand its presence in the country considerably.