TORONTO -- The Toronto stock market closed higher as the latest comments from U.S. political leaders raised hopes for an agreement to head off a fiscal crisis in the United States.

The S&P/TSX composite index closed up 28.7 points to 12,140.33 while the TSX Venture Exchange dipped 0.8 of a point to 1,205.37.

The Canadian dollar shook off early losses to rise 0.29 of a cent to 100.82 cents US.

The TSX had initially tumbled more than 100 points, extending the losses from Tuesday, which had been triggered by comments from Senate Majority Leader Harry Reid. He said there had been "little progress" in talks to avoid going over the fiscal cliff.

Markets started to revive back from the worst levels of the morning after House Speaker John Boehner said he was optimistic that a deal can be reached with President Barack Obama to avert the so-called fiscal cliff at the end of next month.

Economists say the combination of steep tax increases and spending cuts would significantly cut economic growth and likely push the U.S. back into recession and damage other economies around the world.

New York indexes also erased early lows as the Dow Jones industrials surged 106.98 points to 12,985.11.

The Nasdaq climbed 23.99 points to 2,991.78 while the S&P 500 index added 10.99 points to 1,409.93.

Adding to optimism was a remark from President Barack Obama that he believes that members of both parties can reach a "framework" on a debt-cutting deal before Christmas.

And an administration official says two of President Barack Obama's top negotiators on the "fiscal cliff" will meet separately on Thursday with top political leaders.

Still, analysts questioned whether a comprehensive deal can be reached this late in the year.

"I think people who anticipate a resolution prior to year-end are being very optimistic because just right off the bat, many of the legislators don't really see themselves as having mandate since they have been defeated," said Norman Raschkowan, North American strategist at Mackenzie Financial Corp.

"The most likely case is that they establish the framework for an agreement and they announce sort of the bare bones of that framework prior to year-end with the expectation that by the end of January or early February, a detailed plan would be put in place."

The turnaround on the TSX was led by a gain of almost two per cent in the mining sector as December copper also pared early sharp losses to close one cent lower to US$3.52 a pound. Lundin Mining (TSX:LUN) rose 25 cents to $5.28.

Inmet Mining Corp. is rejecting an unsolicited takeover offer worth $4.9 billion by First Quantum Minerals Ltd. The miner (TSX:IMN) says First Quantum (TSX:FM) offered 50 per cent of the deal's value, or up to $2.46 billion, in cash and the other 50 per cent in the Vancouver miner's shares. Inmet shares soared $9.20 or 17.42 per cent to $9.20 while First Quantum lost 34 cents to $20.80.

The gold sector also turned positive, up about 0.5 per cent as December gold on the New York Mercantile Exchange dropped $25.80 to US$1,716.50 an ounce. Centerra Gold (TSX:CG) advanced 26 cents to C$9.32 while Goldcorp Inc. (TSX:G) improved by 36 cents to $39.31.

The energy sector rose almost 0.4 per cent while January crude dropped 69 cents to US$86.49 a barrel. Canadian Natural Resources (TSX:CNQ) gained 32 cents to C$28.24.

Imperial Oil (TSX:IMO) shares were up 47 cents to $42.98 as it said it will invest $1.55 billion to acquire a half interest in the assets of Celtic Exploration Ltd. (TSX:CLT). The Calgary-based company is currently in the process of being fully acquired by Imperial parent ExxonMobil Canada Ltd., which announced a $3.1-billion bid for Celtic in October. Celtic shares were unchanged at $26.

Utilities led TSX losses with TransAlta Corp. (TSX:TA) down 51 cents to $14.91.

The tech sector was also negative but Research In Motion Ltd. (TSX:RIM) shares turned positive, up 30 cents to $11 on heavy volume of 8.4 million shares. The stock had been lower amid word that it had lost a contract dispute over the use of Nokia patents. A Swedish arbitrator has ruled that RIM breached a contract between the companies and is not entitled to manufacture or sell wireless local access network (WLAN) products without first reaching a royalties agreement with Nokia.

Elsewhere in the tech sector, CGI Group Inc. (TSX:GIB.A) dropped 93 cents to $23.12 as the company posted a net loss of just under $170 million or 58 cents per diluted share in the latest quarter, compared with a profit of $69.6 million or 26 cents per share in the year-earlier period. Revenue rose to $1.61 billion from just over $1 billion in the fiscal 2011 quarter. Ex-items, the company said it would have had net earnings of $100 million or 37 cents per share, down from 39 cents per share a year earlier.

In other corporate news, shares in Quebec-based engineering firm SNC-Lavalin fell 92 cents to $39.99 after the province's anti-corruption squad arrested former CEO Pierre Duhaime. He faces charges of fraud, conspiracy to commit fraud and use of false documents.

There was also data that showed that U.S. sales of new homes dipped 0.3 per cent in October to a seasonally adjusted annual rate of 368,000, below expectations of 382,000. Also,the September sales pace was slower than initially thought. Still, house sales are 20.4 per cent higher than the same month last year, supporting other data that show the housing market recovering.