(Adds analyst quotes, details on background, updates prices)
* TSX up 188.16 points, or 1.55 percent, at 12,331.32
* Nine of the TSX's 10 main groups move higher
By Fergal Smith
TORONTO, Jan 26 (Reuters) - Canada's main stock index rose on Tuesday as shares in energy companies and banks were helped higher by a recovery in the price of oil to above $31 a barrel, while a 12-week high for the price of gold helped lift mining stocks.
The most influential risers were mostly energy stocks and banks, which together account for more than half of the index's weight and have both fluctuated in recent days in tandem with moves in the oil market.
"It is clear that the bears are pretty exhausted here and the bulls are starting to take over," said Colin Cieszynski, senior market analyst at CMC Markets Canada.
The market has rebounded from a three-year low last week. Earlier this month, it was down more than 20 percent from its September 2014 record high, indicating a bear market.
The energy group climbed 4 percent, with Suncor Energy Inc adding 3.5 percent to C$31.00 and Canadian Natural Resources jumping 6.1 percent to C$26.42.
U.S. crude prices settled at $31.45 a barrel, up 3.7 percent, as investors hoped OPEC and non-OPEC producers were inching closer to a deal to reduce output amid one of the biggest supply gluts in decades.
"It shows what happens when the commodity prices start turning around and some of the negativity starts going away," said Cieszynski.
The materials index rose 2.1 percent, including a 3 percent gain for Goldcorp Inc to C$15.10. Spot gold rose 1.3 percent to $1,121.76 an ounce.
The Toronto Stock Exchange's S&P/TSX composite index closed up 188.16 points, or 1.55 percent, at 12,331.32. Nine of the index's 10 main groups were in positive territory.
"The breadth of the rally outside of resource sectors is also very strong and very encouraging," said Cieszynski.
Financial sector stocks gained nearly 1 percent, with Toronto-Dominion Bank rising 1.4 percent to C$50.87 and Bank of Montreal up 1.5 percent at C$72.78.
Valeant Pharmaceuticals International Inc rose 4.9 percent to C$138.87, while Canadian National Railway Co was up 1.6 percent at C$71.29.
Retailer Metro Inc fell 3.8 percent to C$40.27 after earlier hitting an all-time high on better-than-expected profit and a hike in its dividend.
Additional reporting by Alastair Sharp; editing by Nick Zieminski and Tom Brown