TORONTO - The Toronto stock market closed higher Thursday as good news on BP's oil spill in the Gulf of Mexico and talk of a settlement between Goldman Sachs and U.S. regulators sparked buying in the final minutes of the session.

The S&P/TSX composite index had been flat most of the day on weak U.S. and Chinese economic data. But it closed up 121.61 points at 11,741.77 after BP said late in the afternoon that oil from its broken well has stopped gushing into the Gulf of Mexico for the first time since April.

BP said all valves had been shut on a new cap over the busted well in an experiment to stop the spill and its shares surged $2.75, or 7.6 per cent, to US$38.92 on the New York Stock Exchange.

Stocks also rallied as the U.S. Securities and Exchange Commission said it planned a "significant announcement" after the market close.

While it's not clear what the SEC may say, investors began buying on the belief that the government and Goldman Sachs Group Inc. had settled the charges that grew out of the sale of securities based on risky mortgages.

Goldman shares were up $6.16, or 6.16 per cent, at US$145.22.

The TSX Venture Exchange was ahead 2.3 points at 1,386.86.

The Canadian dollar moved down 0.44 of a cent to 96.26 cents US amid a report from Statistics Canada that manufacturing sales increased for the eighth time in nine months in May, advancing 0.4 per cent to $44.8 billion. The motor vehicle and parts industries were the primary contributors to the higher sales.

The TSX energy sector turned positive after the BP announcement, rising 0.66 per cent even as the August crude contract on the New York Mercantile Exchange dropped 42 cents to US$76.62 a barrel. Imperial Oil (TSX:IMO) was ahead 81 cents at C$40.39 while Canadian Natural Resources (TSX:CNQ) rose 22 cents to C$37.

Financials were a big late day support in the wake of the Goldman Sachs speculation. The sector was up one per cent with TD Bank (TSX:TD) ahead 76 cents at $72.88, while Bank of Montreal (TSX:BMO) rose 77 cents to $62.19.

The industrials sector also advanced, up 1.61 per cent with Canadian National Railways (TSX:CNR) ahead $1.75 at $63.82 and Canadian Pacific Railway (TSX:CP) up $1.12 at $60.71.

Gold stocks were higher as the August bullion contract on the Nymex ticked up $1.30 to US$1,208.30 an ounce. Barrick Gold Corp. (TSX:ABX) climbed 43 cents to C$44.86.

Commodity stocks had led TSX losers earlier in the session after data showed that China's rapid growth is slowing as the impact of its massive stimulus eases and Beijing clamps down on a credit boom.

The world's third-largest economy grew by 10.3 per cent in the second quarter compared with a year earlier, still a rapid pace compared with North America and western Europe but down from the first quarter's 11.9 per cent expansion.

China's ability to help drive a global recovery might be dented if slower growth cuts its appetite for commodities from Canadian companies, factory machinery from the U.S. and Europe, and industrial components from Asian suppliers.

"It's really been the part of the world that has been driving the rebound and certainly the increased demand for commodities," said Kate Warne, Canadian markets specialist at Edward Jones in St. Louis.

"So I think commodities are especially sensitive to the perceptions of what is going on in China."

The TSX base metals component was the only decliner, down 0.5 per cent as the September copper contract in New York was up about a third of a cent at US$3.01 a pound. Teck Resources (TSX:TCK.B) lost 23 cents to C$34.28 while Western Coal Corp. (TSX:WTN) slipped nine cents to C$4.14.

Stocks had also been depressed earlier in the session in the wake of a report from the Philadelphia Federal Reserve that its manufacturing survey for the Philadelphia region tumbled to 5.1 in July from 8.1 in June. The report served to reinforce worries that the American economic recovery is slowing.

New York markets had been deep in the red but ended up closing little changed as the Dow Jones industrial average finished 7.41 points lower at 10,359.31.

The Nasdaq composite index was off 0.76 of a point at 2,249.08 while the S&P 500 index added 1.31 points to 1,096.48.

In other corporate news, Nexen Inc. (TSX:NXY) says higher output and prices during the second quarter helped earnings come in at $255 million, or 49 cents a share, beating analyst estimates. That's up from $20 million or four cents per share in the same period of 2009. Cash flow and revenue were also higher and its shares advanced 94 cents to $22.32.

Thompson Creek Metals Co. Inc. (TSX:TCM) is diversifying beyond its traditional base of molybdenum with a $650-million deal to acquire junior miner Terrane Metals (TSXV:TRX) and its copper and gold assets. Thompson Creek shares fell 48 cents to $9.42 while Terrane shares jumped 19 cents or 16.24 per cent to $1.36.

Calgary-based Smart Technologies Inc. began trading for the first time Thursday on both the Nasdaq and the Toronto Stock Exchange (TSX:SMA) after completing a US$660-million IPO in Canada and the United States. The company priced its 38.8 million shares at US$17 each, and its shares closed at $17.80, down from a high of $18.35.

Opti Canada Inc. (TSX:OPC), a partner in the Long Lake oilsands project in northern Alberta, reported a big loss in its latest quarter as the company took a hit on its hedging contracts and faced higher operating costs and currency losses. Opti lost $152 million or 54 cents a share in the second quarter. That compares with a loss of $9 million or four cents a share for the same 2009 period. Its shares lost seven cents to $1.88.