The bank made a net profit of €352 million ($460 million), compared with a loss of €761 million in the same period a year earlier, owing in part to lower provisions against losses on risky loans, a statement said.
Analysts polled by Dow Jones Newswires had forecast a much smaller net profit of €121 million.
For the first half of the year, Commerzbank posted a net profit of nearly €1.1 billion, as it decreased loan loss provisions in the second quarter to €639 million from €993 million in the same period a year earlier.
"On the basis of the pleasing development in results in the first six months, we now assume that in a stable market environment we will conclude 2010 as a whole with a profit," chairman Martin Blessing was quoted as saying.
Commerzbank made a second-quarter operating profit of €243 million, against a loss of €223 million in 2009, and Blessing stressed that reducing risks had become a top priority.
"Stability is more important to us than maximizing short-term earnings," he said.
Commerzbank has struggled to integrate the loss-making Dresdner Bank and carried out an emergency recapitalisation in January 2009 with €18.2 billion in German government aid that left the state with a stake of 25 percent.
Repaying that debt, which will allow the bank to regain its independence, is another top priority.