TORONTO, Jan 14 (Reuters) - Canada's main stock index edged up to a record high on Wednesday as geopolitical uncertainty helped underpin energy shares, offsetting a steep decline for technology stocks.

The S&P/TSX Composite Index ended up 46.11 points, or 0.1%, at 32,916.47, surpassing the record closing high it posted on Monday.

U.S. stocks fell, with technology shares declining as investors moved into more defensive areas.

"As we see it, a lot of what's happening today and the last couple of days is revolving around geopolitical risk, geopolitical tensions," said Philip Petursson, chief investment strategist at IG Wealth Management. "Right now it's really emanating out of Iran."

Fears of Iranian supply disruptions helped push the price of oil to its highest level in nearly three months before giving up some gains.

Recent strength in oil "is being priced into oil stocks and that's what's driving the TSX marginally higher," Petursson said.

Energy added 2.6%, with shares of Cenovus Energy Inc up 4.5%.

Safe-haven buying helped lift gold to a record high. The materials group, which includes metal mining shares, gained 1.1%.

Just two of the 10 major sectors ended lower, including technology. It lost 4.5%, led by a 5.9% decline for the shares of e-commerce company Shopify Inc.

Consumer discretionary was down 0.3% as Aritzia Inc gave back some of its recent gains for a second straight day, losing 6.3%.

(Reporting by Fergal Smith in Toronto and Utkarsh Tushar Hathi in Bengaluru; Editing by Jonathan Ananda and Diane Craft)

By Fergal Smith