Oil slide wipes out market gains

Stocks failed to hold gains after a strong rally, as oil's late-day plunge overshadowed the bounce in tech, transports and industrials.

Oil sank, with Brent and West Texas Intermediate both down more than 4 percent after the International Energy Agency cut its forecast for oil demand and said prices may drop further. More than a dozen energy names in the S&P 500 hit new 52-week lows, and the S&P energy sector fell into bear market territory Tuesday, with a more than 20 percent decline from its highs.

Meanwhile, the Dow transports jumped more than 2 percent, as airlines recovered some of the losses made on fears of a wider Ebola outbreak hampering travel. FedEx and UPS, companies that also benefit from lower energy prices, rose, as Delta, UAL, Southwest and JetBlue moved higher.

Art Cashin, director of floor operations at UBS, noted the S&P 500 on Tuesday rallied to 1,898, near resistance before falling back. He pointed out that the morning high was just around the level stocks were trading at Monday before a sharp drop in the 3 p.m. hour.

A final leg down in oil prices in afternoon trading shaved much of the market's gains, and the Dow turned slightly lower after an earlier triple-digit gain. Stocks were attempting to recover after the worst three-day selloff since 2011. The S&P 500 closed slightly higher, up nearly 3 points at 1877.

WTI crude fell 4.6 percent to $81.84, in its biggest percentage drop since November 2012 and the lowest settle price since June 2012.

Read MoreThe top 10 signs for when selling is over

Oil's drop accelerated into the NYMEX close. "The question is are these fears of slowing economic conditions and good supply...are they lasting enough to keep the market here," said Gene McGillian, an analyst with Tradition Energy.

As energy tumbled, tech staged a rebound, with the Nasdaq up slightly and the small-cap Russell 2000, less influenced by energy names, up nearly 1 percent.

Tech was helped by Skyworks Solutions, up more than 7 percent after the Apple supplier raised its guidance for earnings and revenue for the quarter ended in September. Intel, reporting after the close, also was trading higher.

The good news for semis comes after Microchip Technology lowered its forecast for its fiscal second quarter after chip sales fell short. Beaten-down chip names like Cree, RF Micro Devices and NXP Semiconductor also jumped, while Microchip was lower.

"Energy is a little more diverse for small (caps). Oil prices are going down because the potential for global growth is slower," said Steve DeSanctis, director of small cap research at BofA Merrill Lynch. He said small cap energy was up about 24 percent earlier in the year, and is now down 40 percent.

DeSanctis said small caps may have bottomed, and they could benefit from earnings as more start to be reported.

The earnings season has just gotten underway, and big bank earnings were mixed Tuesday but comments from CEOs were fairly upbeat. Citigroup was higher on an earnings beat, and JPMorgan was slightly lower after reporting an earnings miss but better revenue.

Read MoreBank CEOs see U.S. economy improving

One trader noted the big surge in volume in ETFs late Monday suggested an asset allocation trade in such things as the consumer discretionary sector, First Trust Consumer Discretionary Fund FXD, financials, First Trust Exchange Traded Alphadex Fund FXO and materials—First Trust Materials Alphadex Fund FXZ.

As stocks bounced early Tuesday, Treasury yields came off their lows. The 10-year, following Europe's lead, touched 2.176 percent but edged higher to 2.20 percent. Jeffrey Gundlach, CEO and CIO of DoubleLine Capital, told CNBC that he believes rates put in a bottom and that stocks likely hit their high of the year when Alibaba went public.

Read MoreWe've seen the bottom for rates: Gundlach

David Ader, chief Treasury strategist at CRT Capital, said it's unclear whether the bottom is in for rates, and that it will depend more on the behavior of other markets.

"The fact is we're not here because of intrinsic reasons that are the Treasury market alone. We're here because of events in other markets," he said.

Read MoreMortgage rates dip below four percent

"If stocks do what they did yesterday again, we'll blow 2.20 and fall further," he said. It was trading with a yield of 2.19 percent late in the day.

Ader pointed out that the five-year and seven-year notes outperformed longer duration securities, and that suggested an asset allocation trade away from things like high yield, emerging market or European sovereign debt.

"It has less to do with the Fed than those markets," he said, adding that where the central bank does matter is in the market's shifting view that there is less risk of a rate hike than there had been several weeks ago.

"The market (a month ago) was giving 8.3 percent odds fed funds would be no more than 50 basis points by the end of next year. Today, they're giving us over 27 percent odds," he said.

Ader said another wild card is how different asset classes will deal with the end of quantitative easing, which the Fed is expected to announce at its next meeting.

The dollar was slightly higher Tuesday and gold continued to make gains above $1,200, a key threshold. It was trading at $1,234 an ounce Tuesday.

Read MoreOil rout continues as IEA cuts view

But the big commodities mover was oil. Brent futures were trading near $85 per barrel, a near four-year low. It is now down 25 percent from its high.

Traders said the late-day selling in oil was technical in part, but there was a big liquidation in the final hour.

"It's the IEA and statements from Kuwait that they're not looking to cut oil production and the bad German data. It keeps coming, like a one-two punch," said John Kilduff, oil analyst with Again Capital.

Oil prices have been reeling from softer demand from a weaker global economy—particularly in Europe—and on a sufficient supply picture, boosted by growing North American production. The strengthening U.S. dollar has also been a factor.

Reuters on Tuesday reported that an Iranian oil source said that Iran could live with lower oil prices, an unexpected comment. Saudi Arabia, in cutting prices, has signaled it will defend its market share by accepting lower prices and some other OPEC members appear to be in agreement.

"I think at this point you're looking at another $10" decline, Kilduff said. "At around $70, it will begin to affect our own domestic production."

Oil stocks continued to choke Tuesday on the decline in crude. Chevron fell to a new 52-week low, and Apache was trading at its lowest price in 18 months Tuesday, while Transocean sank to a 10-year low. Noble, Chesapeake and Pioneer Resources were also at August 2013 lows.

Murphy Oil was trading at a 22-month low, and Southwestern Energy hit a 20-month low.