In this Feb. 5, 2015 file photo the logo of a Mercedes car is photographed during an annual press conference of Daimler AG in Stuttgart, Germany. Credit: AP Photo/Michael Probst, File

German auto maker Daimler reaped strong profits in the second quarter as demand for its Mercedes luxury cars continued to rebound from the depths of the pandemic, generating cash that the company can invest in its shift to electric vehicles.

Profit margins reached into double digits for the third quarter in a row at 12.8% thanks to rising sales numbers and vehicles carrying higher profits dominating the sales mix, the Stuttgart-based said Wednesday. That helped boost the company's cash pile to 20.9 billion euros ($24.6 billion) at the end of the quarter, from 20.1 billion euros at the start.

CEO Ola Kallenius said the company would use its cash to invest in electric car technology and developing a more software-focused company. Those are key fields as the industry is disrupted by regulatory demands for zero-emission cars in the next few years, and by the longer-term development of partly or fully autonomous vehicles as well as software-driven services enabling people to use cars only when they need them, such as through smartphone apps.

"Our transformation towards emission-free and software-driven mobility is supported by a high level of free cash flow in the industrial business," Kallenius said in a statement. "We are implementing our strategy at full speed."

Kallenius said vehicle production was still hampered by the shortage of semiconductor components that has hit the auto industry worldwide. The company said the shortage would continue to affect the business in the second half of the year.

The company is introducing new and has said it aims to have a carbon-dioxide neutral lineup by 2039 although it hasn't specified a date for exiting production of internal combustion vehicles—which are generating the profits for the transition to zero local emission vehicles in any case. The company is set to overhaul its strategy for Mercedes-Benz on Thursday.

The update comes in the wake of newly ambitious targets proposed by the European Union's executive commission to reduce emissions of carbon dioxide, the main greenhouse gas blamed by scientists for global warming and climate change. The commission called for a 100% reduction in CO2 emissions from cars by 2035, meaning a de facto end to gasoline and diesel engines in Europe.

The company plans to spin off its truck division later this year, in part because cars and trucks are moving toward different technologies, with cars expected to use batteries while long-haul trucks in some cases will rely on hydrogen fuel cells to achieve zero local emission transport in coming years.

For the , Daimler's came in at 3.7 billion euros, up from a loss of 1.9 billion euros in the April-June period in 2020 when the company had to shut down plants during the early phase of the COVID-19 pandemic. Revenue rose 44% to 43.5 billion euros.