The Toronto stock market shook off early losses and closed with a slight gain Wednesday.

The S&P/TSX composite index inched up 10.63 points to 13,330.28, its fifth record high in the past six session, amid a major merger in the agriculture sector.

Five of the 10 TSX1 0 main groups were higher, with the resource-laden materials group reversing course late in the day to end 1% higher on a rise in gold prices. Strength in gold stocks offset softer energy issues, which did not follow a surge in the price of crude.

Gold rallied 3% to a nine-month high near the US$700 an ounce level due to fund buying and higher oil prices.

Barrick Gold rose 92¢, or 2.5%, to $37.25, while Goldcorp climbed 92¢, or 2.9%, to $32.95.

The oil and gas group shed 0.2% despite a rebound in the price of oil, which rose more than 2% to US$60.07 a barrel on supply worries.

EnCana slid 72¢, or 1%, to $68.46.

Financials also saw losses, easing 0.3%, as negative sentiment over inflation data south of the border likely seeped into the Canadian market.

The information technology sector was down 1.1%, after computer maker Hewlett-Packard failed to impress investors with its latest earnings report.

Elsewhere, shares of Canadian National Railway were up 51¢, or 1%, at $54.45 amid news that Ottawa was planning legislation to force striking employees back to work.

Shares of Agricore United rose $1.58, or 13.2%, to $13.58 on news that Canada’s No. 3 grain company, privately held James Richardson International, had bid for Agricore, Canada’s biggest grain handler, countering a hostile bid by Saskatchewan Wheat Pool.

The junior S&P/TSX Venture composite index rose 12.48 points to 3,136.63.

The Canadian dollar rose 0.79 of cent to US86.19¢.

On Wall Street, blue-chip stocks fell on higher-than-expected consumer inflation.

The Dow Jones industrials closed 48.23 points lower to 12,738.41. The Nasdaq composite index edged up 5.38 to 2,518.42 and the S&P 500 index dipped 2.05 to 1,457.63.

The U.S. Labor Department said prices at the consumer level rose 0.2% in January. That was down from a 0.4% rise in December, but it was higher than the 0.1% increase that had been expected.