* TSX ends down 0.3% at 21,639.10

* For the week, the index falls 1.7%

* Consumer staples falls 1.6%

* Tech gains 0.9%, with Shopify up 4.6%

June 14 (Reuters) - Canada's main stock index fell to a three-month low on Friday, extending recent underperformance versus U.S. markets, as investors shunned the financial and energy shares that have a heavy weighting in the index in favor of technology shares.

The Toronto Stock Exchange's S&P/TSX composite index ended down 59.01 points, or 0.3%, at 21,639.10, its lowest closing level since March 6.

For the week, the index was down 1.7%, its biggest weekly decline since October. It was the fourth straight weekly decline for the TSX, which is the longest such stretch since May 2023.

"It looks like it's really diverging from the S&P 500 which is closing out a very strong week," said Brian Madden, chief investment officer at First Avenue Investment Counsel Inc.

"Money is professionally managed and a lot of money chases performance and performance is very much in the United States and not in Canada."

The TSX is up 3.3% since the start of the year, falling well below the 13.9% gain for the S&P 500 which has a higher weighting in high-flying technology shares.

The U.S. benchmark closed slightly lower on Friday but was holding near the record closing high it posted on Thursday.

There is "good leadership from the technology group in the States. Canada, despite Shopify's best efforts today, is not really enough to hold up our whole market."

The Toronto market's technology sector rose 0.9%, with e-commerce company Shopify Inc up 4.6%.

But most major sectors ended lower, with financials , which account for 29% of the index's weighting, down 0.5% and energy, which has a 20% weighting, falling 0.7%.

The price of oil settled 0.2% lower at $78.45 a barrel, giving back some of its weekly advance.

Defensive sectors also lost ground, with consumer staples down 1.6% and communication services ending 1.2% lower. (Reporting by Fergal Smith in Toronto and Shristi Achar A and Nikhil Sharma in Bengaluru; Editing by Shreya Biswas and Alistair Bell)