(Adds details throughout; updates prices to close)

*

TSX ends up 56.92 points, or 0.3%, at 20,277.41

*

Energy rises 1.5%; oil settles 1.2% higher

*

Materials sector gains 3%

*

Scotiabank ends 2.5% lower

TORONTO, Nov 29 (Reuters) - Canada's main stock index rose on Tuesday as higher commodity prices bolstered resource shares although gains were kept in check by a decline in Bank of Nova Scotia shares after the company reported quarterly results.

The Toronto Stock Exchange's S&P/TSX composite index ended up 56.92 points, or 0.3%, at 20,277.41, moving closer to the five-month high it notched on Friday at 20,383.77.

Scotiabank reported a lower fourth-quarter profit and said it expects earnings next year to take a further hit as the economic downturn offsets gains from higher interest rates. Its shares ended 2.5% lower.

"If I was the CEO of a Canadian bank right now, I would look at my stock price and earnings that have held up well, and would seek to use this opportunity to protect the balance sheet just in case things worsen," said Barry Schwartz, portfolio manager at Baskin Financial Services.

Canada's economy performed much better than expected in the third quarter, but an early indication that growth stalled in the fourth quarter could prompt the Bank of Canada next week to slow its campaign to hike interest rates.

The TSX will rally in the coming year and move to a record high in 2024 as inflation pressures ease and provided an anticipated slowdown in the domestic economy is not too deep, a Reuters poll found.

The energy sector rose 1.5% as the price of oil settled 1.2% higher at $78.20 a barrel on hopes for a relaxation of China's strict COVID-19 controls.

The materials group, which includes precious and base metals miners and fertilizer companies, added 3% as gold and copper prices rose.

HSBC agreed to sell its business in Canada to Royal Bank of Canada for C$13.5 billion ($10 billion) in cash. RBC's shares ended up 0.4%. (Reporting by Fergal Smith; Additional reporting by Johann M Cherian in Bengaluru; Editing by Richard Chang)