Commerzbank swung to a net profit in the third quarter despite weak markets as the German lender focuses on a major overhaul. 

The €472m net profit at Germany's second-largest lender after Deutsche Bank was broadly in line with analysts' expectations for a profit of €477m, according to a Reuters poll. 

The profit, which compares with a loss of €637m in the second quarter and €288m a year ago, comes as the bank goes through a major restructuring to increase profitability. 

It is reducing its staff to 36,000 by 2020 from 43,000 at the end of 2015.

The bank has also been focusing on digitising its back office and expanding its retail customer base.

"We have made good progress in laying foundations for our transformation this year," the bank's chief executive Martin Zielke said.

"In the interest of sustainable long-term profitability, we are focussing on growth. We have grown both in terms of clients and assets," he added. 

The bank reiterated that it was still expecting to eke out a "slightly positive" net profit for the full year of 2017. 

In a sign of the bank's improving financial health, its Common Equity Tier 1 capital ratio rose to 13.5% from 13% at the end of the second quarter.