(Updates with official closing numbers, adds details)
TORONTO, Dec 20 (Reuters) - The Toronto Stock Exchange's main index ended with a small gain on Thursday as an advance in materials and Research In Motion helped offset a slide in banking shares.
The materials group added 1.3 percent, pulled higher by net gain leader Potash Corp of Saskatchewan (POT.TO), which was up C$7.95, or 6.4 percent, at C$131.96.
But the gold subsector was off 0.6 percent as gold prices slipped on the firmer U.S. dollar. Yamana Gold Inc (YRI.TO) fell 33 Canadian cents, or 2.8 percent, to C$11.61, and Barrick Gold (ABX.TO) was down 24 Canadian cents, or 0.6 percent, at C$37.40.
Research In Motion RIM.TO gained C$4.43, or 4 percent, to C$106.52, lifting the tech sector 0.6 percent, ahead of the BlackBerry-maker's quarterly results.
After the closing bell, RIM beat expectations on its third-quarter profit, but delivered a subscriber outlook that fell short of what analysts had predicted.
The S&P/TSX composite index .GSPTSE closed up 17.19 points, or 0.13 percent, at 13,407.01 with seven of the TSX's 10 main groups higher. The index has had small gains for two days in a row, but has closed lower in four out of six sessions.
On the downside, the banking sector lost 1 percent as North American financial stocks were rattled by a larger-than-expected loss from U.S. investment bank Bear Stearns Cos Inc BSC.N.
As well, MBIA Inc (MBI.N), the world's largest bond insurer, said it has exposure to $30.6 billion in complex mortgage securities that it insures. The amount is larger than its entire net worth.
In Toronto, all of the major banks declined, including Toronto-Dominion Bank (TD.TO), which fell C$1.20, or 1.7 percent, to C$68.85.
Canadian Imperial Bank of Commerce (CM.TO) was down 63 Canadian cents, or 0.9 percent, at C$70.51 the day after it warned of the possibility of a "large charge" in its first-quarter results on its exposure to the U.S. subprime market. ($1=$1.00 Canadian) (Reporting by Leah Schnurr; editing by Janet Guttsman)