The Toronto Stock Exchange's S&P/TSX composite index closed up 62 points, or 0.4 percent, at 15,516.23, its highest close since May 12.

Gains for the index came despite a sell-off in technology shares and North Korea tensions that weighed on Wall Street.

"Canada is getting a little bit more attractive from a valuation standpoint," said James Robertson, managing director, portfolio solutions group at Manulife Asset Management. "You are starting to see more capital moving into Canada."

The Toronto market has been held back this year by the lower price of oil, one of Canada's major exports, and a stronger Canadian dollar.

But the loonie retreated ahead of a speech on Wednesday by Bank of Canada Governor Stephen Poloz, while U.S. crude oil prices reached their highest since April, settling up 3.1 percent at $52.22 a barrel.

The energy group climbed 1.7 percent, with Pembina Pipeline Corp rising 3.4 percent to C$43.55 and Encana Corp advancing 1.7 percent to C$14.13.

Five of the index's 10 main groups ended higher, with financials gaining 0.2 percent.

"I think the negativity around the financial names has dissipated, Robertson said.

Investors have worried that a slowdown in Canada's housing market will hold back loan growth for banks.

The materials group, which includes precious and base metals miners and fertilizer companies, added 0.7 percent as safe-haven buying of gold helped boost gold mining shares.

Bombardier Inc extended previous losses to hit a more than four-month low on news that Siemens AG will likely choose French rival Alstom SA over the Canadian company in a multibillion-dollar rail merger.

Montreal-based plane and train maker Bombardier is also awaiting a U.S. court ruling, expected to be made public on Tuesday, on a CSeries dumping complaint by Boeing Co.

Bombardier shares pared some earlier losses but still fell 4.0 percent to C$2.14, while the overall industrials retreated 0.3 percent.

The technology group declined 1.1 percent, with Shopify Inc falling 4.6 percent to C$141.64.

Air Canada, which counts fuel as one of its major costs, lost 7.3 percent to C$25.50.

(Additional reporting by Solarina Ho; Editing by W Simon and Lisa Shumaker)

By Fergal Smith