TORONTO -- The Toronto stock market gave up a solid early gain and closed lower Wednesday as an impending deadline for dealing with the U.S. budget and debt ceiling continued to cast a shadow over trading.

The S&P/TSX composite index had been up as much as 65 points, but closed down 12.18 points at 12,836.71, reflecting growing weakness in telecoms, industrials and smartphone maker BlackBerry.

The Canadian dollar also erased early gains and was down 0.11 of a cent at 96.96 cents US.

U.S. indexes moved deeper into negative numbers amid reports that Wal-Mart Stores Inc. (NYSE:WMT) was cutting orders from suppliers this quarter and next to address rising inventories. It's the latest sign that Wal-Mart's sales have been slow after the company cut its full-year sales forecast back in August.

The retailer later responded that the reports were "misleading." Wal-Mart stock was down $1.10 to US$74.65 after falling as low as $73.56.

Meanwhile, investors looked ahead to an Oct. 1 deadline for American political leaders. At issue is a temporary spending bill required to keep the U.S. government fully open after the start of the new budget year.

The government reaches its borrowing limit, or debt ceiling, early in October. If Congress doesn't raise that limit, the government won't be able to pay all its bills, a blow to confidence in the world's biggest economy.

Treasury Secretary Jacob Lew says the government will have exhausted its borrowing authority by Oct. 17, leaving the United States with just $30 billion cash on hand to pay its bills.

The Dow Jones industrials fell 61.33 points to 15,273.26, the Nasdaq was 7.16 points lower at 3,761.1 and the S&P 500 index was down 4.65 points to 1,692.77.

Investors well remember the last time Democrats and Republicans locked horns over raising the debt limit during the summer of 2011. Indexes were hard hit as traders worried about a possible default and the damage done to the economy from a possible government shutdown. Standard & Poor's ended up downgrading the U.S. credit rating, before a political compromise was reached.

"Last time, I was amazed," said Chris King, portfolio manager at Morgan, Meighen and Associates.

"It backed companies off, it backed consumers off, it was a real suppressant to the economy and it could be similar this time."

On the economic front, U.S. durable goods orders in August were up 0.1 per cent following a 7.4 per cent drop in July. Other data showed that U.S. new home sales rebounded by 7.9 per cent in August to 421,000, the biggest one-month gain since January.

The information technology sector was the biggest percentage decliner, down 1.3 per cent as BlackBerry shares continued to deteriorate as the Globe and Mail reported that Fairfax Financial Holdings Ltd. (TSX:FFH) is seeking more than US$1 billion from other investors to help fund a takeover of BlackBerry Ltd. (TSX:BB) (NASDAQ:BBRY). Fairfax said on Monday that it's leading a group that would buy the Canadian smartphone maker for US$4.7 billion, paying shareholders US$9 a share.

The Globe said that as of Tuesday only one pension fund was seriously considering joining the Fairfax-led consortium -- the Ontario Teachers Pension Plan. BlackBerry fell 52 cents, or 5.9 per cent, to $8.26 on the TSX and lost 52 cents, or 6.15 per cent, to US$8 in New York.

Telecoms and industrials also pressured the TSX with Telus Corp. (TSX:T) down 78 cents to $34.78 while Canadian National Railways (TSX:CNR) fell $1.33 to $102.77.

The TSX gold sector led advancers, up about 2.2 per cent while December bullion gained $19.90 to US$1,336.20 an ounce. Goldcorp Inc. (TSX:G) rose 45 cents to C$26.84.

December copper was ahead two cents to US$3.27 a pound and the base metals sector was up 1.5 per cent with Teck Resources (TSX:TCK.B) ahead 38 cents to C$28.58.

The energy sector was up a slight 0.09 per cent while oil prices moved lower as data showed that U.S. supplies increased by 2.6 million barrels last week, against a drop of 1.5 million barrels that analysts expected. The November contract on the New York Mercantile Exchange dropped 47 cents to US$102.66 a barrel. Suncor Energy (TSX:SU) advanced 46 cents to C$37.09.