However, the German automaker stuck to its full-year forecasts, avoiding the profit warnings that have beset the industry and helping to push its shares higher on Thursday.

“There are no major hiccups and as the product momentum is improving, so will profitability and cashflow. In an extremely volatile auto world, this is very good news,” analysts at Evercore ISI said in a note to clients.

Carmakers are having to make huge investments into cleaner and self-driving technologies just as demand in China, the world’s biggest auto market, is falling and a trade war between Washington and Beijing is curbing global economic growth.

BMW said earnings before interest and taxes (EBIT) fell to 2.2 billion euros ($2.4 billion) in second quarter, hit by the cost of trying to meet stricter emissions rules due in 2021.

Investments in property, plant and equipment jumped 39% as the company opened a factory in Mexico and retooled its plants to introduce more flexible production lines help it double sales of electric and hybrid cars by 2021.

The Munich-based company said the operating margin at its automotive division fell to 6.5% from 8.6% a year earlier, despite a 1.5% rise in vehicle sales over the same period.

FILE PHOTO: The BMW logo is seen on a car in Nice, France, April 8, 2019. REUTERS/Eric Gaillard/File Photo

But analysts said the margin compared favorably with Mercedes-Benz’s 3.6% and Audi’s 8% given BMW sees higher volumes and a better mix of model sales in the second half of the year.

BMW reiterated its forecast for a significant decrease in group profit before tax in 2019 as well as a slight increase in vehicle deliveries, and an EBIT margin of 4.5%-6.5% in the automotive division.