* TSX falls 13 points, or 0.10 percent, to 12,745.38 * Five of 10 main sectors decline * CN Rail drops 3.2 percent after results * Miners gain as commodity prices climb By John Tilak TORONTO, July 23 (Reuters) - Canada's main stock index pulled back on Tuesday after a four-day rally as a decline in shares of Canadian National Railway Co following its results offset strength in mining shares. Shares of CN Railway, the country's largest railroad, fell 3.2 percent after the company posted an 11 percent rise in second-quarter adjusted profit but said the second half might be challenging. The stock was the single biggest factor leading the market lower. It had run up before earnings were released after the market close on Monday. Rival Canadian Pacific Railway Ltd gave back 1.8 percent to C$130.18. The decline of the two rail companies took the industrials sector down 1.1 percent. The Toronto market hit a seven-week high earlier in the session before giving up gains. The materials sector was the biggest positive influence, rising 1.5 percent as shares of gold and base metal miners rose. "From a valuation perspective and also from a sentiment perspective, things are turning around" for metals and mining companies, said Marcus Xu, president and portfolio manager at MY Capital Management Corp. "The commodities side of the market is always going to be volatile, but I think a long-term trend is starting," he added. "As the market starts to get more comfortable, you'll see more money gravitate to risky sectors and names." Gold hit a one-month high as speculators bought back bearish bets ahead of an option expiry later this week. First Quantum Minerals Ltd jumped 6.6 percent to C$17.37 and was the biggest supporting influence of any one stock. Goldcorp Inc rose 2.4 percent to C$30.69. The Toronto Stock Exchange's S&P/TSX composite index closed down 13 points, or 0.10 percent, at 12,745.38. Five of the 10 main sectors on the index were in the red. Financials, the index's most heavily weighted sector, lost 0.4 percent. Bank of Nova Scotia gave back 1 percent to C$58.35.