Aug 25 (Reuters) - Canada's main stock index ended at a record closing high on Wednesday as upbeat quarterly results from Royal Bank lifted financials, although the surging energy sector was flat for the first time in four days as oil prices steadied.

The Toronto Stock Exchange's S&P/TSX composite index added 0.19% to close at 20,587.32 points, surpassing the previous closing record set on Aug. 11. The index is up 17.9% this year.

Royal Bank of Canada (RBC) also hit an all-time high after the lender comfortably beat analysts' expectations for third-quarter profit, lifting the broader financial index by 0.5%.

But bank and insurers stocks pulled back from their highs after Canada's ruling Liberal Party said it would hike the corporate tax rate for the two industries to 18% from 15% on all earnings over C$1 billion ($793 million) if reelected on Sept. 20.

"Based on a rough back of the envelope approach, the taxes payable for the Big Six banks would increase around 16% in aggregate. So it could definitely have an impact," said Maria Khoury, senior vice president for North American financial institutions' credit ratings at DBRS Morningstar.

However, including tax deductions and other considerations, and depending on what types of income are subject to the higher rate, the final figure would likely be less, she said.

Recouping losses from their biggest fall in more than a month last week, Canadian equities are tracking their seventh straight month of gains on global optimism about a steady post-pandemic economic recovery.

"We've got a lot of sector rotation going on beneath the surface (in Canada) and all the cyclical sectors like energy, miners - which got hit a few weeks ago amid concerns of more lockdowns - have rebounded in the last few days," said Gregory Taylor, portfolio manager at Purpose Investments.

A Reuters poll found the stock index is now expected to rise only marginally by the end of the year, but then extend its record-setting rally in 2022.

Heavyweight technology stocks edged higher, tracking a rise in their U.S. peers, which have shrugged off signs of slowing pace of economic growth to scale record highs.

Energy stocks were flat after surging 6% in the past three sessions on a bounce in oil prices.

HIGHLIGHTS

* RBC, Canada's biggest bank by market value, rose 0.8% after beating reporting stronger-than-expected earnings.

* National Bank of Canada fell 0.6% despite reporting better-than-expected earnings with some investors not impressed by the quality of the profit beat.

* Air Canada edged down 0.8%. Canada's top airline said on Wednesday it would require all employees to get vaccinated against COVID-19, as the fast-spreading Delta variant drives an increase in infections.

* The largest percentage gainers on the TSX were Lithium Americas and Canaccord Genuity, while Osisko Mining Inc and Sandstorm Gold led the decliners.

(Reporting by Amal S in Bengaluru and Nichola Saminather; Editing by Sriraj Kalluvila and Richard Pullin)