* TSX up 138.77 points, or 1.1 percent, at 12,454.89 * Materials sector leads index up amid U.S. budget uncertainty * Canpotex deal boosts potash companies By Allison Martell TORONTO, Dec 31 (Reuters) - Canada's main stock index rose more than 1 percent on Monday, boosted by the materials sector, as U.S. lawmakers pushed for a last-minute agreement to avoid the "fiscal cliff" that could put the U.S. economy into recession. Gold rallied in the afternoon after news of a potential deal, and held its gains as President Barack Obama said a deal to prevent the tax hikes and sharp spending cuts was in sight, but not yet complete. "As always, they leave it to the very last moment, and then something almost invariably emerges, even if it's not the major, game-changing plan that they wanted," said Gavin Graham, president at Graham Investment Strategy. Graham said investors were likely buying gold because of inflation that could follow a resolution of the U.S. budget dispute. Gold is seen as a hedge against inflation. He said upbeat manufacturing data out of China was also helping the Canadian market: "It's evident now that China is emerging from its slowdown." That data boosted iron ore and copper prices, and Teck Resources Ltd, Canada's largest diversified miner, was an influential gainer on the TSX, rising 3.5 percent to C$36.29. At 3:00 p.m. (2000 GMT) the Toronto Stock Exchange's S&P/TSX composite index was up 138.77 points, or 1.1 percent, at 12,454.89. The index was on track to finish up about 4 percent for the year. "If you're a Canadian and you bought the index, you got killed by the commodities this year," said David Baskin, president of Baskin Financial Services. "You got whacked by the gold stocks." Gold miners underperformed in 2012 as soaring operating and development costs cut into profits despite historically high gold prices. Goldcorp Inc was one of the most influential gainers in the index on Monday, however, rising 3.5 percent to C$36.68. The heavyweight materials sector rose 2.8 percent overall. Financial stocks, which have been rising and falling with the perceived chances of a U.S. budget deal in recent weeks, were up 0.4 percent in volatile trading. Energy stocks rose 1.3 percent as oil prices edged higher on optimism about the U.S. budget talks. Suncor Energy Inc led the index higher, rising 1.8 percent to C$32.79. Canpotex Ltd, the offshore sales agency for Potash Corp of Saskatchewan, Mosaic Co and Agrium Inc , said it struck a six-month agreement to supply a subsidiary of China's Sinofert Holdings Ltd. Potash Corp rose 2.0 percent to C$40.52, and Agrium was up 2.0 percent at C$99.78. The Canadian Imperial Bank of Commerce said it would pay $149.5 million to the estate of Lehman Brothers Holdings Inc to resolve litigation over a collateralized debt obligation tied to the bankruptcy of the former Wall Street bank. Shares fell 0.7 percent to C$80.02, and CIBC was the most influential negative stock in the index.