Stocks pared gains just before the close, but remained on track to snap a three-day losing streak thanks to news that gasoline demand was stabilizing.
The Dow Jones Industrial Average rose more than 35 points after slipping at the open, and after ending slightly lower on Tuesday amid further signs of economic weakness.
Among Dow components, DuPont advanced, while Procter & Gamble fell.
TheS&P 500 and the Nasdaq also gained. The CBOE Volatility Index, widely considered the best gauge of fear in the market, fell to nearly 17.
Among key S&P 500 stocks, energy and materials gained, while consumer staples fell.
News that gasoline supplies are stabilizing and distillate stocks (heating oil and diesel fuel) fell more than expected, combined with an upbeat forecast on the North American oil services business from Halliburton's chief financial officer helped to lift the market, said Marc Pado, U.S. market strategist at Cantor Fitzgerald.
Halliburton shares gained more than 4 percent, while shares of smaller oilfield services providers contributed to a pop in theRussell 2000, Pado said. The small-cap index was up around 1 percent, while the Oil Service HOLDRS Trust gained more than 2 percent.
Wednesday's move continues a trend showing that money "doesn't want to leave the market," he added. When investors get worried, they move into defensive stocks, like consumer staples and utilities, but if they can find any good reason to buy stocks they shift into leadership sectors, like energy, materials and technology.
"This is classic, a typical pullback phase," Pado said. "When there's good news of any sort, you get a little bounce. That tells me there are willing buyers."
Oil prices roseon Wednesday despite an unexpected 616,000 barrel rise in crude stockpiles as distillate supplies fell 2.04 million barrels to the lowest level since April 2009.
U.S. light, sweet crude gained 1.74 percent to settle at $101.32 a barrel, while in London, Brentcrude rose 2.13 percent to settle at $114.93.
In stocks news, Martha Stewart Living soared on news from the media and merchandising company retained Blackstone Advisory Partners to explore strategic alternatives. The company also announced that Martha Steward is expected to rejoin the Martha Stewart Living board in the third quarter.
American International Group fell after the U.S. Treasury sold 200 million shares at $29 a share, slightly more than the Treasury needs to recoup its investment. The total $8.7 billion sale included 100 million shares sold by AIG.
Retail stocks slipped after some disappointing earnings. Polo Ralph Lauren sank to the bottom of the S&P 500 after reporting disappointing fiscal fourth-quarter profits as a result of the earthquake in Japan. And American Eagle Outfitters skidded despite doubling its first-quarter earnings, as sales and margins dropped.
Costco fell after reporting a boost in gasoline salesin the last quarter hurt its profit margins, despite posting a rise in profits.
And Hormel also slumped despite posting better-than-expected sales, and offering a strong earnings outlook.
Netflix jumped after news Mark Zuckerberg, CEO of Facebook, said at a conference in Paris that the social networking firm has been in talks with Netflix about developing social tools, Scott Redler, chief strategic officer at T3live.com, said in a note to clients.
The stock, which Redler owns, could be set to "make a big momentum move," he wrote.
And Cisco slipped after news that language in its quarterly performance report filed with the Securities and Exchange Commission was slightly revised say revenue growth this quarter would be "relatively flat," instead of "flat to up 2 percent," the language the networking firm used in an earlier earnings conference call.
On the initial public offering front, FreeScale Semiconductor Holdings was expected to raise about $1 billion in a 43.5 million share offering slated for Wednesday under the ticker "FSL." The share price was reportedly lowered to $18 to $20 a share from $22 to $24.
Precious metals gained on Wednesday, with silver ending more than 4 percent higher to $37.64 an ounce. Gold rose 0.22 percent to settle at $1,526.60.
In the bond market, the U.S. Treasury auctioned $35 Billion in 5-Year notes at a high yield of 1.81 percent, and a bid-to-cover ratio of 3.20.
In Europe, the Greek Prime Minister’s office denied the prospect of a snap election in the country in a CNBC interview. Greece has been forced to step up austerity efforts and the Greek people are increasingly angry about the spending cuts they face.
In U.S. economic news, a 3.6 percent drop in durable goods ordersin April, released on Wednesday, was the largest drop in six months and the latest in a string of weaker-than-expected economic news, due largely to a fall in aircraft and motor vehicle orders. March durable goods orders were revised up to a 4.4 percent gain from a rise of 4.1 percent.
But the market largely shrugged off the news.
"Two things take the sting out of the report," said Jeff Kleintop, chief market strategist for LPL Financial. "The number did come in weaker than April, but we had a much stronger March than thought," Kleintop said. And, durable goods orders tend to be weak in the first month of a new quarter, he added.
Still, "this does confirm that there is a little bit of a soft spot related to the ripple effects from the Japanese tsunami and earthquake," Kleintop said.
Also in U.S. economic news, the Mortgage Bankers Association'sseasonally adjusted index of mortgage application activity rose 1.1 percent last week, the fourth weekly rise. And home prices fell 0.3 percent in March from February, and prices fell 5.8 percent in the 12 months through March, according to the Federal Housing Finance Agency.
European shares rosein a technical rally as concerns over Greece's debt restructuring lingered.
On Tap This Week:
THURSDAY: GDP, USDA Agricultural Trade Outlook, jobless claims, corporate profits, natural gas inventories, seven-year Treasury note auction, money supply; earnings before-the-bell from Sony and Tiffany.
FRIDAY: Personal income and spending, consumer sentiment, and pending home sales.
More on CNBC.com