TORONTO - The Toronto stock market lost most of its early Thursday gains and closed barely ahead at the end of trading due to losses in telecom and industrial stocks.

The S&P/TSX composite index erased most of a 72-point advance to inch up 2.9 points to 13,406 while the TSX Venture Exchange gained 31.75 points to 1,985.91.

The Canadian dollar rose against the greenback, up 0.75 of a cent to 104.31 cents US -- the highest close since May 10.

The market found support from energy stocks as oil prices got a boost from positive American employment news.

A day before the release of the U.S. non-farm payrolls report, payroll firm ADP reported that the American private sector created 157,000 jobs last month. Economists had expected the economy to crank out a total of 90,000 jobs last month.

"Helping the bullish case is the fact that we've seen two solid employment readings (from the Institute for Supply Management) -- both the manufacturing and service sectors picked up in June -- and a solid 150,000 jobs gain in tomorrow's payrolls report now seems to be in the cards," said BMO Capital Markets economist Robert Kavcic.

Canadian employment numbers also come out on Friday and Statistics Canada is expected to report the economy created around 10,000 jobs in June.

Oil prices took off despite data from the U.S. Energy Information Administration that U.S. crude oil inventories declined by 900,000 barrels, far short of the 2.5 million barrel decline that analysts had forecast. But gasoline inventories fell by 600,000 barrels last week versus an increase of 500,000 barrels that had been expected.

"The gasoline supply figure was a big improvement from a month or so ago, when you had a number of weeks where U.S. gasoline consumption was declining, which goes against the normal seasonal patterns," said Robert Gorman, chief portfolio strategist at TD Waterhouse.

"And you could really see the U.S. consumer reining in consumption as the price hit around US$3.50 a gallon at the pumps."

The August crude contract on the New York Mercantile Exchange was up $2.02 at US$98.67 a barrel.

The energy sector rose 0.68 per cent with Suncor Energy (TSX:SU) up 57 cents to C$39.22 and Canadian Natural Resources (TSX:CNQ) rose 54 cents to $41.67.

The base metals sector rose 0.57 per cent as metal prices also advanced with the September copper contract in New York up 11 cents to US$4.44 a pound. Teck Resources (TSX:TCK.B) improved by 58 cents to C$50.98 while Quadra FNX Mining (TSX:QUX) climbed 36 cents to C$14.82.

The gold sector weakened late in the session even as worries about the European debt crisis helped push the precious metal higher for a third day. The August contract climbed $1.40 to US$1,530.60 an ounce and Goldcorp Inc. (TSX:G) gained 52 cents to C$48.48 and Barrick Gold Corp. (TSX:ABX) faded 34 cents to $44.30.

The tech sector also supported the TSX while Research In Motion Ltd. (TSX:RIM) climbed $1.08 to $27.87.

The rise came amid criticism from shareholder advisory firm Glass Lewis and Co. over RIM's plan to appoint a committee to study the chairman's role at the company instead of going ahead and splitting the roles of CEO and chairman.

Rooftop solar panel company Opsun has signed a deal with Celestica Inc. (TSX:CLS) to manufacture high-efficiency solar panels in Ontario. Financial terms of the deal were not released and Celestica shares gained six cents to $8.50.

The telecom sector was the weakest group, with Rogers Communications (TSX:RCI.B) down 80 cents at $37.90 and BCE Inc. (TSX:BCE) falling 55 cents to $37.84.

Railway stocks helped push the industrial sector down with Canadian National Railways (TSX:CNR) down to 64 cents to $76.48.

New York markets racked up a solid advance as traders hoped that the ADP jobs data provided an indication that the U.S. economy is moving out of a soft patch that depressed stocks in the second quarter.

"Yes we have a slower than average recovery. Growth is moderate. Call it 2.5 per cent, maybe three per cent. That's not such a bad thing if it's accompanied by low inflation and interest rates, which would seem to be the case," added Gorman.

"So from our standpoint, we're pretty comfortable with that. It seems to be panning out but obviously a few data points do not a market make."

The jobs data sent the Dow Jones industrial average charging ahead 93.47 points to 12,719.49. The Nasdaq composite index was up 38.64 points to 2,872.66 while the S&P 500 index rose 14 points to 1,353.22.

The retail segment also lifted New York after Target Corp., Costco Wholesale Corp. and other major retailers reported stronger sales for June.

News Corp. shares were down four cents to US$17.43 following a four per cent Wednesday after the Murdoch media empire unexpectedly killed off Britain's muckraking News of the World tabloid Thursday. The move followed a public backlash over mushrooming allegations of criminal behaviour at the paper, including bribing police officers for information and hacking into the voice mail messages of celebrities, politicians and the families of murder victims

Elsewhere, shares in telecom equipment maker DragonWave Inc. (TSX:DWI) were up 26 cents to C$5.53 even as the company surprised analysts with a US$9.9-million loss in the first quarter. Its North American revenue plunged 81 per cent from the same time last year.

Cogeco Inc. (TSX:CGO) deepened its losses to $56.7 million in the third quarter as it wrote off its cable division's net investment in its Portuguese operations. The company said the three-month results were equivalent to a loss of $3.39 per share, compared with a loss of $10.7 million, or 64 cents per share, in the year-earlier period. Its shares were ahead nine cents to $42.99.