* TSX closes down 27.58 points, or 0.21 percent, at 13,371.84
* Banks lead gains, while energy and railway stocks weigh
TORONTO, Oct 28 (Reuters) - Canada's main stock index closed lower on Monday after briefly reaching a two-year high, weighed down by several heavyweight energy and mining stocks as well as a retreat by the country's two main railways.
Offsetting those declines, the country's largest banks turned in another positive performance. Financial stocks have jumped in recent weeks as investors grew more confident that the U.S. Federal Reserve will stick with its monetary stimulus for longer.
"If you have an optimistic outlook for the North American economy, they (Canadian banks) are still attractively priced," said Barry Schwartz, a portfolio manager at Baskin Financial Services.
"We're in a slow growth but steady-as-she-goes economy and there will be pockets of fantastic strength and areas of weakness," he said, suggesting resource stocks could still struggle.
Some of the country's heavyweight mining and energy stocks slipped on the day, with Canadian Natural Resources off 1.9 percent at C$32.69 and Suncor Energy Inc down 0.5 percent at C$37.46. Energy stocks have risen some 13 percent from a trough in June.
The two main railways both slipped, with Canadian National Railway Co down 1 percent at C$114.03 and Canadian Pacific Railway Ltd off 1.3 percent at C$148.17. The pair are still sharply higher than before they posted solid earnings results last week.
Canadian National said on Monday it is still talking with the union representing about 3,300 conductors and other workers and expects the two sides will be able to avoid a strike.
Valeant Pharmaceuticals International Inc slipped 1.9 percent to C$115.34 after it agreed to pay $142.5 million in a settlement with Anacor Pharmaceuticals.
The Toronto Stock Exchange's S&P/TSX composite index closed down 27.58 points, or 0.21 percent, at 13,371.84.
It is still, however, at levels last seen in July 2011, having added 5 percent so far this month.
"We've had a heck of a move already this month in North American markets, particularly in Canada," said Irwin Michael, a portfolio manager at ABC Funds. "There doesn't appear to be a lot of fear right now. It's complacency."
Materials stocks were mixed, with Teck Resources down 2 percent at C$29.76 and Goldcorp Inc up 1.2 percent to C$28.31.
Potash Corp gained 1 percent to C$32.93 after rival fertilizer producer Mosaic Co said it would buy the phosphate business of CF Industries Holding Inc for $1.2 billion.
Meanwhile, banks provided much of the positive impact, with Bank of Nova Scotia adding 0.8 percent to C$62.87 and Royal Bank of Canada up 0.2 percent at C$69.61.
ABC's Irwin said that the index could yet trade higher by the end of the year, but that a shock between now and then was also possible.
"I do think the market will end the year higher than where it is today, but from now until then I suspect we are due for a correction and I think it will be quite healthy for the marketplace," he said.