NEW YORK -- 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 were higher in early afternoon trading. As of 3:30 p.m. the Dow Jones industrial average was up 95 points at 12,973. It had been down as much as 112 points shortly after the opening bell.

The Standard and Poor's 500 was up nine points at 1,408. The Nasdaq composite was up 20 points at 2,988.

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 U.S. back into recession. President Barack Obama said he believed that 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 without reaching a deal.

"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 Pres-ident Barack Obama staying in the White House and Repub-licans retaining control of the House.

Uncertainty about possible higher taxes for capital gains are prompting investors to consider selling stocks, said Johnson.

Many companies are making special end-of-year dividend payments or moving up their quarterly payouts because inves-tors will have to pay higher taxes on dividend income starting in 2013, unless lawmakers reach a compromise on taxes and government spending.