* TSX up 40.16 points, or 0.3 percent, on the day * Ends 2013 at 13,621.55, a 9.6 percent annual gain * Annual gain much smaller than U.S. indices as gold weighs By Alastair Sharp TORONTO, Dec 31 Canada's main stock index closed out 2013 with a broad but modest gain on Tuesday, boosted by higher miners, banks, railways and energy companies, as investors looked optimistically ahead to 2014. "A nice close, and I think the momentum will probably continue on January 2nd," said David Cockfield, a portfolio manager at Northland Wealth Management. "We are looking at people who are buying for 2014, not for the last of 2013. People who were light on the equity side are getting themselves into position," he said. The rise capped a 9.6 percent gain for the Toronto Stock Exchange's S&P/TSX composite index in 2013, a far smaller gain than those notched by the three main U.S. indices. It was the best annual performance since 2010's rise of more than 14 percent. Much of Canada's lag can be blamed on dismal returns from mining stocks, which struggled with rising production costs and volatile prices, while U.S. stocks were more directly boosted by the U.S. Federal Reserve's massive stimulus program. In particular, some of the world's biggest gold miners call Canada home and have seen their shares fall even further than the 28 percent decline in bullion this year - its worst drop in 32 years. Barrick Gold Corp has fallen 46 percent this year, and Goldcorp Inc is down 37 percent. But the pair reversed Monday's losses in the last session of the year, with Goldcorp up 3.6 percent at C$23.04 and Barrick gaining 2.6 percent to C$18.67. The index as a whole ended up 40.16 points, or 0.3 percent, at 13,621.55 points, on the back of modest gains in seven of the index's 10 main sectors. It ended 2012 at 12,433.53. Resource stocks, which make up a large chunk of the overall index, had the biggest positive impact, with Canadian Natural Resources Ltd up 1 percent at C$35.94 and Suncor Energy Inc also adding 1 percent, to C$37.24. Bank of Nova Scotia gained 0.3 percent to C$66.43 and Canadian National Railway Co added 0.5 percent to C$60.56. HIGHER HOPES FOR 2014 The Canadian stock market may deliver its best performance in four years in 2014 as a global economic recovery gathers steam, driving up sagging commodity prices and natural resource shares, a Reuters poll found in mid-December. With Europe pulling itself out of a recession, China showing signs of stabilizing, Japan feeling positive effects of a record stimulus and the U.S. economy entering higher gear, analysts expect the global demand outlook to brighten. And the export-focused Canadian market is seen a beneficiary. "You can stick your neck out a little further in this kind of environment," Northland's Cockfield said. But while a seemingly surer footing for the global economy has many investors confident that Canada's resource stocks will lift their game in the next year, some are still ringing a note of caution. "I don't share everybody's enthusiasm for the markets. They are trading at rarefied levels," said John Ing, president of Maison Placements Canada, referring to U.S. markets overall and specific sectors of the Canadian market such as banks. He said, however, that gold may have a chance to shine again as interest rates on longer-dated bonds rise on the Fed's just-started withdrawal of stimulus that has supported equities for several years. "The byproduct of higher interest rates will be volatility in the market and a return to risk assets, and that's where gold does well." The technology sector, a much smaller piece of the pie, also sank this year, as once world-beating smartphone maker BlackBerry Ltd shed more than a third of its value amid massive losses and an aborted attempt to sell itself.