* TSX falls 34.74 points, or 0.22 percent, at 15,782.16
* Half of TSX's 10 key industry sectors end lower
By Solarina Ho
TORONTO, Oct 18 (Reuters) - Canada's benchmark stock index reversed earlier gains on Wednesday as weaker energy and materials stocks offset a rally in Canadian Pacific Railway shares following better-than-expected quarterly earnings.
Oil and gas companies gave back 0.4 percent as crude prices pared gains following an unexpected fall in U.S. refining rates and diesel and gasoline stock builds that indicated softer demand. weather that caused power outages in parts of Alberta and Saskatchewan also disrupted two crude oil pipelines in Western Canada. Inc's ENB.TO 2.6 percent retreat to C$50.42 accounted for about a tenth of a percent of the index's decline. Transcanada Corp TRP.TO fell 2.2 percent at C$61.96.
Encana Corp ECA.TO , which holds its investor day on Wednesday, tempered some of declines, rising 2.8 percent to C$14.70.
CP Rail CP.TO also stemmed losses and finished up 5.1 percent to end at C$220.36 after the company also raised its full-year profit forecast. results gave a boost to its peer, Canadian National Railway CNR.TO , which gained 0.7 percent to end at C$101.05. The two companies helped lift the industrials sector .GSPTTIN 1.2 percent.
The Toronto Stock Exchange's S&P/TSX composite index .GSPTSE closed down 34.74 points, or 0.22 percent, to finish at 15,782.16. Half of the index's 10 main sectors lost ground.
The index, which is flirting near highs reached in February, has see-sawed back and forth this week after rallying more than five percent since early September.
"It's much better to have two steps forward, one step back. That's a lot more normalizing in our opinion," said Sid Mokhtari, market technician and director, institutional equity research, CIBC World Markets.
"There's a little bit of a pull-back in the commodities related areas," he added.
Mining stocks were squeezed by metal prices, with gold prices falling for a third straight session as the greenback rose amid speculation over who will be the next chair of the U.S. Federal Reserve. prices also fell on profit-taking after its recent surge to three-year highs, though demand expectations from China helped curb losses.
Teck Resources TECKb.TO fell nearly 2 percent to C$27.61, while Barrick Gold ABX.TO fell 0.8 percent to C$20.16. Agnico Eagle Mines AEM.TO was down 1.1 percent at C$55.84.
The materials sector .GSPTTMT lost 0.8 percent, while the gold subsector .SPTTGD retreated 1.3 percent.