The selloff in Macy's stock, a bellwether for department stores, gave investors a reason to unload some shares of Kohl's Corp, down 1.5 percent at $55.11; Nordstrom Inc, down 0.9 percent at $68.12, and Wal-Mart Stores Inc, down 0.3 percent at $74.03. All are expected to report results on Thursday.

Although the weak retail sales pointed to some loss of momentum in the economy, the July reading could give the Federal Reserve more support to move slowly on raising interest rates, a situation that favors investors in equities.

"Investors seem to be looking past the retail numbers and seeing the silver lining, which is that the Fed could be less hawkish and keep interest rates down for longer," said Lawrence Glazer, managing partner at Mayflower Advisors in Boston.

"Domestically, despite some questionable earnings reports, areas like biotech, transports and Amazon all gave a boost to markets today."

All 10 S&P primary sector indexes gained, even as some heavyweights' stocks plunged on missed earnings and downgraded revenue forecasts.

Biotech shares surged, with the Nasdaq Biotech Index climbing 2.1 percent in sync with a rally in the stocks of InterMune Inc and Jazz Pharmaceuticals PLC.

The Dow Jones Transportation Average gained 0.7 percent.

Investors have been sensitive in recent weeks to signs of flaring tensions abroad, but were not affected on Wednesday. The declaration by the White House that the United States would not send combat ground troops to Iraq "has given the market some upward momentum," said Kim Forrest, senior equity research analyst at Fort Pitt Capital Group in Pittsburgh.

The Dow Jones industrial average rose 91.26 points, or 0.55 percent, to close at 16,651.80. The S&P 500 gained 12.97 points, or 0.67 percent, to finish at 1,946.72. The Nasdaq Composite added 44.88 points, or 1.02 percent, to end at 4,434.13.

Wednesday's advance lifted the Dow back into the black for 2014 after last week's sharp selloff had wiped out the year's gains.

For the year, the Dow is now up 0.45 percent.

After the bell, Cisco Systems Inc reported a smaller-than-expected drop in quarterly revenue after the bell and its stock lost 2.9 percent in extended-hours trading. The network equipment maker had expected a revenue decline between 1 percent and 3 percent, but reported a drop of only 0.5 percent instead.

An S&P index of healthcare stocks jumped 1.2 percent during the regular session and led the S&P 500 higher. Vertex Pharmaceuticals shares, the biggest gainer in the S&P 500 healthcare sector, shot up 3.9 percent to $88.75.

Amazon shares gained 2.2 percent to $326.28. Earlier in the day, the company unveiled a $10 credit-card reader and mobile app that will let it grab a bigger share of the mobile payments and bricks-and-mortar retail markets.

The stocks of both King Digital Entertainment plc and SeaWorld Entertainment Inc marked their biggest one-day declines ever following quarterly results that missed analysts' forecasts.

Shares of King, maker of the social media and mobile game "Candy Crush Saga," plummeted 23.1 percent to close at $13.99. SeaWorld shares sank 32.9 percent to end at $18.90 after the company slashed its full-year revenue forecast because of a huge controversy over its amusement park shows featuring killer whales.

About 4.7 billion shares traded on all U.S. platforms, according to BATS exchange data, compared with the five-day average of 5.7 billion. (Editing by Nick Zieminski and Jan Paschal)