(Adds details throughout, updates prices)

* TSX ends down 51.78 points, or 0.25%, at 20,544.11

* Technology falls 2.2%

* Materials group ends 1.3% lower

* Energy gains 1.4%

TORONTO, Jan 27 (Reuters) - Canada's main stock index edged lower on Thursday, giving back its earlier gains, as the prospect of faster interest rate hikes by the U.S. Federal Reserve weighed on technology and gold mining shares.

The Toronto Stock Exchange's S&P/TSX composite index ended down 51.78 points, or 0.25%, at 20,544.11 in another roller-coaster session for stocks. The index closed 1.5% below its session high.

Wall Street also ended lower as investors bet that the Fed would hike as many as five times this year.

Technology stocks, which had soared the past two years thanks in part to very low interest rates, led the falls, ending down 2.2%.

The materials group, which includes precious and base metals miners and fertilizer companies, lost 1.3%, with gold falling to the lowest level in more than two weeks as the U.S. dollar surged.

Oil notched a seven-year high but then settled 0.9% lower at $86.61 a barrel as bets on U.S. rate hikes offset concerns about tight worldwide supply.

"Normalizing production in Libya, Nigeria, Venezuela and in other OPEC nations all suggest that operational risks are now easing. This leaves the conflict between Russia and Ukraine, alongside tensions in the Middle East, as the largest sources of supply uncertainty," analysts at TD Securities wrote in a note.

The energy sector ended 1.4% higher. (Reporting by Fergal Smith; Additional reporting by Ambar Warrick; Editing by Aurora Ellis)