* TSX ends up 0.1% at 21,611.30

* Energy rallies 1.6%; oil settles 1.5% higher

* Ballard Power up on technology partnership

* Materials group adds 0.7%

June 18 (Reuters) - Canada's main stock index ended a three-day losing streak on Tuesday as higher commodity prices boosted resource shares, but the gain was modest with investors weighing U.S. retail sales data that fell short of expectations.

The S&P/TSX ended up 23.42 points, or 0.1%, at 21,611.30, after it posted on Monday its lowest closing level in three months.

U.S. retail sales barely rose in May and data for the prior month was revised considerably lower, suggesting that economic activity remained lackluster in the second quarter. Canada sends about 75% of its exports to the United States.

The data disappointed, "adding to the evidence of a slowing U.S. economy," Colin Cieszynski, chief market strategist at SIA Wealth Management, said in a note.

The energy sector rallied 1.6% as the price of oil extended its recent gains, settling 1.5% higher at $81.57 a barrel, on escalating tensions in Europe and the Middle East.

Ballard Power Systems jumped 6.8% after the fuel cell manufacturer announced a technology partnership with packaging firm Vertiv.

The materials group, which includes metal miners and fertilizer companies, added 0.7% as gold and copper prices rose.

Information technology was a drag, slipping 1.1%, with Lightspeed Commerce Inc ending 5.5% lower.

Industrials and real estate both lost 0.5%. (Reporting by Fergal Smith in Toronto and Nikhil Sharma and Shashwat Chauhan in Bengaluru; Editing by Shreya Biswas and Marguerita Choy)