TORONTO - The Toronto stock market gave up solid gains Wednesday as anxiety over Greece's possible exit from the eurozone trumped early moves to buy up stocks beaten down during a string of losses.

The S&P/TSX composite index had ran ahead as much as 131 points during the morning but ended the session down 16.97 points at 11,326.08. The energy sector led declines as crude prices deteriorated further.

The market has plunged about 400 points over the past three sessions alone.

The deterioration in investor confidence has left the TSX at its worst level since early October of last year, down more than 10 per cent from its most recent highs registered at the end of February.

The TSX Venture Exchange eased 22.3 points to 1,217.77.

But the hunt for safety continued to punish the Canadian dollar. It closed 0.57 of a cent lower at a four-month low of 98.75 cents US.

New York markets also shed early advances despite data showing housing starts rising 2.6 per cent in March while U.S. factory production increased 0.6 per cent in April.

There was limited reaction to news that Federal Reserve policymakers are open to further efforts to stimulate the U.S. economy if growth falters or economic threats escalate.

Minutes of the central bank's April 24-25 meeting stated that "several members" thought additional Fed support could be needed if the recovery lost momentum or if the risks to the economy became great enough. The minutes did not spell out such circumstances

The Dow Jones industrials were 33.45 points lower at 12,598.55.

The Nasdaq composite index lost 19.72 points to 2,874.04 and the S&P 500 index fell 5.86 points to 1,324.8.

Greece has weighed heavily on buying sentiment since an inconclusive election May 6 left no party with enough votes to form a government and Greeks will go back to the polls on June 17.

Many Greeks voted for parties that had been on the fringe of the political spectrum and which want to see the country abandon the tough austerity measures adopted in return for the huge international bailouts that are propping up that country.

Without agreeing to another round of austerity measures, it's conceivable that Greece's partners in the eurozone will withhold the next round of bailout cash. An exit from the euro might then become inevitable.

If Greece leaves the euro, then a precedent would be set that could be taken up by other countries burdened by high debt levels.

"Investors are definitely getting increasingly frustrated that we had heard this story over and over again," said Jeff Bradacs, portfolio manager at Manulife Asset Management.

"As they approach the June deadline, I think investors are really looking for a kind of a decision here on whether they will stay in the eurozone or exit the euro."

The flight from risk continued to drive commodities lower since no one knows how much damage a chaotic Greek exit from the eurozone would have on the broader global economy.

But a higher U.S. dollar has also hammered prices for oil and metals. That's because prices are denominated in U.S. dollars and a higher greenback makes oil and metals more expensive for holders of other currencies.

And even before Greece reoccupied centre stage on markets, commodities and resource stocks were losing ground amid signs of a slowing global economy.

"And a lot of concern there rests on China," Bradacs said.

"Growth in China has been slowing from a very high pace. To get those stocks moving again we need to see more accomodative moves from China to really move our commodity stocks."

On the TSX, losses were led by the energy sector, down 0.7 per cent as the June crude contract on the New York Mercantile Exchange lost $1.17 to US$92.81, its lowest level since last November. Suncor Energy (TSX:SU) slipped 22 cents to $27.45.

Financials also weakened with Manulife Financial (TSX:MFC) down 39 cents to $11.25.

The base metals sector was the biggest advancer, up 1.4 per cent even as copper prices continued to slide with the July contract down four cents to US$3.48 a pound, its lowest level since early January. The metal, viewed as an economic barometer since it is used in so many industries, has plunged 10 per cent this month. Ivanhoe Mines (TSX:IVN) climbed 32 cents to $9.07 while First Quantum Minerals (TSX:FM) ran up 90 cents to C$17.74.

Investors also sold off bullion, which was down $20.50 to US$1,536.60 an ounce, a price not seen since last July. But the gold sector ticked about one per cent higher and Barrick Gold Corp. (TSX:ABX) climbed 48 cents to C$35.71.

Industrial stocks also supported the TSX, with Canadian Pacific Railway (TSX:CP) up $1.69 to $75.86, a day before CP's annual meeting. Shareholders will vote on a proposal from Pershing Square Capital Management, its biggest shareholder, to install a new slate of directors and replace CEO Fred Green with former Canadian National CEO Hunter Harrison.