TORONTO - Three of Canada's largest banks reported stronger-than-expected results on Thursday even as they set aside more money to cover bad loans and detailed a raft of writedowns for credit and market losses.

Toronto-Dominion Bank, Canadian Imperial Bank of Commerce and National Bank of Canada all notched results that were slightly higher than analysts had expected, but the quarter was marred by heavy charges the banks recorded for various losses.

The volume and the size of charges we saw coming out of TD and CIBC were a little bit surprising (but) ... core earnings excluding all these charges at the three banks all exceeded expectations, said Dundee Securities analyst John Aiken.

To be sure, write-downs by Canada's big lenders were not unexpected given market volatility early in the year that reduced the value of investments and assets. Restructuring costs also came as no surprise.

Even so, analysts were treating the underlying profits reported by the banks with some caution.

The problem hinges on the quality of earnings, because we've seen a lot of revenues this quarter which may not necessarily be repeatable, Aiken said.

Shares of TD rose 2.4 percent to C$51.49 shortly after market open in Toronto, while CIBC shares fell 2.3 percent to C$55.70 and National shares rose 3.2 percent to C$51.15.

TD Bank, Canada's second-largest, said profit fell in the second quarter ended April 30 as provisions for bad loans nearly tripled to C$656 million from C$232 million a year earlier. Bad loans have been increasing at Canadian banks as the economy struggles and unemployment rises.

TD earned C$618 million, or 68 Canadian cents a share, down 27 percent from a year earlier. The results included charges on amortization of intangibles, losses on hedging, restructuring and shareholder litigation.

Excluding those items, TD had earnings of C$1.23 per share, above analyst expectations of C$1.13, according to Reuters Estimates.

We're feeling quite good about these results, TD Chief Executive Ed Clark said in a statement. All TD businesses are holding up very well under the weight of the recession in Canada and the United States.

Results were a bit grimmer at CIBC, where Canada's fifth-largest bank reported a net loss of C$51 million, or 24 cents a share. The loss was narrower than the C$1.11 billion loss a year earlier, but the Toronto-based bank posted C$475 million in pretax debt writedowns.

Excluding the charges and special items, CIBC said cash earnings were C$1.44 a share, above analysts' average forecast of C$1.39 per share profit, according to Reuters Estimates.

Core EPS and credit losses were marginally higher than we had looked for. Writedowns were greater than we had anticipated and retail banking continues to lack revenue momentum, RBC Capital Markets analyst Andre-Philippe Hardy said in a research note.

CIBC set aside C$394 million to cover credit losses, up from C$176 million a year earlier. The bank's large credit card portfolio has been hit as consumers struggle to pay their bills with unemployment rising.

CIBC Chief Executive Gerald McCaughey said losses in structured credit had hurt results, but noted that the losses occurred early in the quarter before the market improved.

The rate of deterioration in the broader economy appeared to slow and liquidity levels recovered during the quarter -- both of which are encouraging signs as we head into the last half of the year, McCaughey said in a statement.

Canada's sixth-largest bank, National Bank of Canada, said its profit jumped 46 percent in the second-quarter, helped by a strong performance from its financial markets division.

Excluding writedowns, the bank earned C$261 million, or C$1.53, during the quarter, up from C$229 million, or C$1.41, for the same time a year earlier.

Analysts had expected a profit of C$1.21 a share, according to Reuters Estimates. ($1=$1.12 Canadian)

(Additional reporting by Scott Anderson; Editing by Frank McGurty)