NEW YORK (AP) -- Stocks gained on signs that lawmakers are edging toward a deal that would help the U.S. avoid the "fiscal cliff."
Indexes shrugged off an early loss and rose in afternoon trading Wednesday. The Dow Jones industrial average closed up 106.98 points at 12,985.11. It had been down as much as 112 points in early trading.
The Standard and Poor's 500 was up 10.99 points at 1,409.93. The Nasdaq composite rose 23.99 points to at 2,991.78.
Huge tax increases and spending cuts will come into effect Jan. 1 if no deal on the U.S. budget is reached. Economists say the measures could push the country back into recession. President Barack Obama said he believed both parties can reach a "framework" on a debt-cutting deal before Christmas, while House Speaker John Boehner told reporters that he was optimistic a deal could be reached, according news outlets including CNBC.
Craig Johnson, a Minneapolis, Minn.-based technical market strategist at Piper Jaffray, said lawmakers realize that there is too much at stake to allow the deadline to pass.
"I don't think that anybody in Washington is going to do something so draconian, or so negative, that we're going to trigger a recession," Johnson said. "There will be some compromise."
Concern that the U.S. will go over the fiscal "cliff" has weighed on stocks since the Nov. 6 elections returned a divided government to power, with President Barack Obama staying in the White House and Republicans retaining control of the House.
Uncertainty about a possible increase in capital gains taxes has been prompting investors to sell stocks, said Johnson.
As the third-quarter corporate earnings period draws to a close, investors and traders have become increasingly fixated on the negotiations to cut the budget deficit. Before Wednesday's gain, the market slumped Tuesday after Senate Majority Leader Harry Reid said he was frustrated by the lack of progress in talks. The two moves canceled each other out, leaving both the Dow and the S&P 500 little changed for the week.
"We're all on pins and needles waiting for every bit of news, or rumors, coming out of Washington," said Ryan Detrick, a Cincinnati, Ohio-based technical analyst at Schaeffer's Investment Research. "That's what Wall Street is focused on. Everybody is watching the fiscal cliff."
Many companies are making special end-of-year dividend payments or moving up their quarterly payouts because investors will have to pay higher taxes on dividend income starting in 2013, unless lawmakers reach a compromise on taxes and government spending.
Costco, the wholesale club operator, surged $6.07 to $102.58 after the company said it would pay a special dividend of $7 a share next month, in addition to its regular quarterly dividend. Las Vegas Sands Corp. rose 5.3 percent Tuesday after the casino operator said it would distribute about $2.26 billion to shareholders before the end of the year. It rose another 1.3 percent Wednesday, gaining 60 cents to $49.96.
With the market's attention focused on the outcome of the "cliff" negotiations, some investors caution that the weakness in third-quarter corporate earnings bode poorly for the stock market.
"Think of corporate earnings as the canary in the coal mine," said Douglas Cote, chief market strategist at ING U.S. Investment Management. "Corporations are the first ones to signal that there is something going on with economic growth around the world."
Company earnings fell 0.9 percent in the third quarter, data provider FactSet said in a report Nov. 23. If they earning finish the period lower, it would mark the first decline in three years.
In economic news, U.S. sales of new homes dipped 0.3 percent in October, though they're up 20.4 percent for the year, according to a government report. Stable home prices suggest the housing market is steadily recovering.
A pickup in consumer spending and steady home sales helped lift economic growth in October and early November in most parts of the United States, the Federal Reserve said in its Beige Book survey released Wednesday. The one exception was the Northeast, which was slowed by Superstorm Sandy.
The yield on the 10-year Treasury note fell to 1.63 percent from 1.64 percent.
Among stocks making big moves:
— Green Mountain Coffee Roasters surged $7.91, or 27.3 percent, to $36.86 after the beleaguered coffee company reported strong fourth-quarter results and issued earnings and revenue forecasts that far exceeded the market's expectations.
—Fresh Market Inc. plunged $7.46, or 12 percent, to $52.78, after the company's fiscal third-quarter profit fell short of analysts' expectations.