The Toronto Stock Exchange's composite index ended up 88.59 points, or 0.4%, at 20,286.20.

In the United States, the S&P 500 and the Nasdaq finished in the red as fears over whether attempts to curb decades-high inflation growth could tip the U.S. economy into recession dampened investor risk appetite.

The TSX's decline since the start of the year, at 4.4%, is much less than for some other major benchmarks. It has been cushioned by a heavy weighting in commodity-linked shares.

The energy sector climbed 2.5% on Tuesday, helped by a gain of nearly 4% for thermal oil producer MEG Energy. The materials sector, which includes precious and base metals miners and fertilizer companies, added 1.4%.

Gold was up 0.7% at about $1,866 per ounce, while the price of oil settled down 0.5% at $109.77 a barrel.

Financials advanced 0.9%, ahead of earnings from Canada's major lenders with Bank of Nova Scotia and Bank of Montreal reporting results on Wednesday.

Canada's top six banks are expected to post an average 12% drop in second-quarter earnings sequentially, as increased expenses and loan-loss reserves and lower investment banking revenues outweigh strong loan growth and margin expansion from rising interest rates.

Domestic preliminary data for April showed that factory sales rose 1.6% from the previous month, largely driven by higher sales of petroleum and coal products, and that wholesale trade edged 0.2% higher.

(Reporting by Fergal Smith; additional reporting by Amal S in Bengaluru; editing by Jonathan Oatis)

By Fergal Smith