Shares of Bristol-Myers Squibb Co (>> Bristol-Myers Squibb Co) shot up 3 percent to $49.73. The rally came a day after the drugmaker said a late-stage trial testing its immunotherapy nivolumab in advanced melanoma patients was halted early after it was determined that the drug was likely to prolong survival.

Pfizer (>> Pfizer Inc.) gained 1.7 percent to $29.80, Merck & Co. (>> Merck & Co., Inc.) rose 1.6 percent to $58.86, and the S&P healthcare index <.SPXHC> ended 1.1 percent higher, giving the S&P 500 its biggest boost.

Shares of CBS (>> CBS Corporation) jumped 6.2 percent to $62.48 after the U.S. Supreme Court ruled that online TV startup Aereo Inc violates copyright law by using tiny antennas to provide subscribers with broadcast network content via the Internet. Comcast Corp (>> Comcast Corporation) shares rose 1.1 percent to $53.21. Shares of the Walt Disney Co (>> The Walt Disney Company), which owns ABC News, advanced 1.5 percent to $83.90 and helped bolster the Dow.

The S&P 500's gains followed two days of losses, putting the index on track for a decline of 0.2 percent for the week.

"You do hear people talking about us being in some kind of a bubble, but I do not see that at all," said Bryant Evans, investment advisor and portfolio manager at Cozad Asset Management, in Champaign, Illinois. "The stock prices are reflecting reasonable valuations."

The Dow Jones industrial average <.DJI> rose 49.38 points or 0.29 percent, to 16,867.51. The S&P 500 <.SPX> gained 9.55 points or 0.49 percent, to 1,959.53. The Nasdaq Composite <.IXIC> added 29.40 points or 0.68 percent, to 4,379.76.

Monsanto Co (>> Monsanto Company) also boosted the S&P 500. The stock climbed 5.1 percent to $126.73 after the world's largest seed company raised the low end of its full-year outlook. Monsanto also said it plans to offer debt to help it finance a $10 billion stock buyback.

The healthcare sector also benefited from more merger news. Medical Action Industries (>> Medical Action Industries) surged 93.5 percent to $13.68 on its heaviest one-day volume ever after Owens & Minor Inc (>> Owens & Minor, Inc.) agreed to buy the company for about $208 million. Owens rose 1.5 percent to $35.38.

On the downside, shares of refiners declined after U.S. officials allowed energy companies to export light crude oil, or condensate, after it has been minimally processed. Valero Energy (>> Valero Energy Corporation), down 8.3 percent at $51.35, was the S&P 500's biggest percentage decliner, followed by Marathon Petroleum (>> Marathon Petroleum Corp), down 6.3 percent at $80.97.

The major indexes slipped at the open after the economic data, but investors quickly moved on. The U.S. economy contracted in the first quarter at an annual rate of 2.9 percent, the sharpest drop in five years, though activity was affected by a harsh winter, and there are indications that growth has since rebounded. In another negative data point, U.S. orders for durable goods unexpectedly fell 1 percent in May.

(Editing by Nick Zieminski and Jan Paschal)

By Caroline Valetkevitch