Stocks ended near the highs of the session, reversing a three-day losing streak as commodity prices rebounded, and as the Federal Reserve gave no indication in its latest minutes that it plans to tighten monetary policy soon.
The Dow Jones Industrial Average gained 80.60 points, or 0.65 percent, to close at 12,560.18.
Oil giants ExxonMobil and Chevron rose along with oil prices, and were among stocks that led the blue-chip index higher.
Hewlett-Packard led Dow laggards for a second day after the tech giant posted disappointing earnings results on Tuesday and received a downgrade from JPMorgan to "neutral" from "overweight." The brokerage also cut the PC maker's price target to $42 a share from $55, saying HP's revised outlook for the fiscal third quarter and the full year is a "major disappointment." In addition, at least four other brokerages also cut their price targets on the firm.
TheS&P 500 rose 11.70 points, or 0.9 percent, to close at 1,340.68, while the tech-heavy Nasdaq rose 31.79 points, or 1.14 percent, to close at 2,815.00. The CBOE Volatility Index, widely considered the best gauge of fear in the market, fell to nearly 16.
Among key S&P 500 sectors, materials and energy gained, while utilities fell, in a reversal of a trend seen over the last couple sessions.
The market got a lift on Wednesday from the dollar, which traded lower most of the session, and the fact "the negativity in the market is taking a little bit of a breather," said Quincy Krosby, market strategist at Prudential Financial.
Another factor is the expiration of stock index futures and options on Friday, Krosby said. "That really does tend to skew the markets a few days before," she said.
Also, market participants are beginning to think the Federal Reserve will continue to support an accommodative monetary policyin the months ahead.
On Wednesday, the Fed released policy minutes from its April meeting that outlined the central bank's thinking about how to tighten monetary policy when the time comes. The Fed stressed that their talk of any exit strategy doesn't mean they are ready to tighten monetary policy soon.
Most Fed officialsprefer to tighten policy through interest rate hikes rather than asset sales, according to the minutes of the Federal Reserve's policy setting meeting, which were released on Wednesday.
The central bank indicated they would eventually cut the Fed's portfolio, and that selling mortgage-related debt would be a priority, Reuters reported, describing the discussions of an exit strategy as "intense."
Oil prices rebounded after a surprise drop in gasoline inventories, followed by an unexpected fall in crude supplies, the Energy Information Administration reported Wednesday. U.S. light, sweet crude rose 3.29 percent to settle at $100.10 a barrel, while in London, Brentcrude rose 2.1 percent to close at $112.30.
The dollar traded flat against a basket of currencies, after trading lower earlier in the session. Precious metals pricesgained, as gold settled up 1 percent to $1,495.60 an ounce, while silver settled up 4.8 percent at $35.09 an ounce.
The news in personal computer stocks wasn't all gloomy, as Dell led the tech sector higher after the PC maker reported better-than-forecast results. In addition, at least 12 brokerages raised their price targets on the firm.
Elsewhere in earnings news, Deere slipped even after the heavy-equipment maker beat earnings estimatesthanks to strong demand and a weak dollar.
BJ'sbeat expectations as more consumers turned to the wholesaler for food and gasoline, while Abercrombie & Fitch also posted better-than-expected earnings.
Target , meanwhile, sank after the retailer topped earnings estimates, but fell short on sales.And Staples plunged after the office-supply chain posted disappointing same store sales and a weaker-than-expected profit. In addition, S&P Equity upgraded the firm to "buy" from "hold."
SodaStream soared after the maker soda machines for the home raised its outlook for the year, and reported strong sales.
Among other tech stocks, Research In Motion gained after Sanford C. Bernstein upgraded the Blackberry maker to "market perform" from "underperform," saying the stock is cheap, and is unlikely to deteriorate further despite the fact the company's management "remains in denial of challenges facing the company."
And shares of Hershey fell after news CEO David West will become CEO of Del Monte Foods, which was taken private by Kohlberg Kravis Roberts earlier this year. West's departurecomes less than four years since he became Hershey's CEO.
Volume on the consolidated tape of the New York Stock Exchange was 3.4 billion shares, while 884 million changed hands on the NYSE floor.
LinkedIn is expected to sell $341 million worth of shares to the public this evening. This comes after the social networking firm raised the expected price range of its IPO by 30 percent Tuesday. The firm is expected to start trading on the NYSE tomorrow under ticker symbol "LNKD." (Read More: Watch LinkedIn for Signs of Social Media Bubble)
Also on the IPO front, Oaktree Capital Management is planning to list its shares on the NYSE in a deal valuing the cmpany between $8 billion and $9 billion, according to the Financial Times.
Delphi Automotive said it has chosen JPMorgan and Goldman Sachs to lead an IPO that could value the auto parts maker at more than $10 billion, sources told Reuters.
And smartphone game maker PopCap Games said it may go public as soon as November, CEO David Roberts said at a news conference, Reuters said.
On the economic front, falling mortgage rates boosted home loan refinancing last week. The Mortgage Bankers Association'sseasonally adjusted index of mortgage application activity rose 7.8 percent in the week ended May 13, boosted by a 13.2 gain in refinancings. Home loan applications fell 3.2 percent.
European stocks closed higher, boosted by gains in techs and miners.
On Tap This Week:
WEDNESDAY: Fed's Bullard speaks; earnings after-the-bell from Limited Brands.
THURSDAY: Weekly jobless claims, existing home sales, Philadelphia Fed survey, leading indicators, money supply, Halliburton shareholder meeting, Intel shareholder meeting, McDonald's shareholder meeting, Sallie Mae annual meeting, LinkedIn IPO; earnings from GameStop and Sears before-the-bell and Gap after-the-bell.
FRIDAY: JCPenney shareholder meeting, Macy's shareholder meeting, Time Warner shareholder meeting; earnings from Ann Taylor before-the-bell.
More on CNBC.com