NEW YORK (AP) --- A rally for technology companies helped U.S. stocks recover some of their recent losses Thursday, but trading remained uneven as investors tried to figure out if the tensions between the U.S. and other nations will spill over into a trade war.
Technology companies and banks were responsible for the bulk of the gains. Amazon surged and shook investors in two separate industries. The online retailer said it's buying online pharmacy PillPack, which led to sharp losses for drugstores and companies that distribute prescription medications to pharmacies. Amazon also announced that it is launching its own delivery van business, which hurt UPS and FedEx. U.S. crude oil rose to its highest price since November 2014.
Stocks started the day at their lowest levels in almost a month. Contradictory reports from U.S. officials about trade policy have led the market to lurch between gains and losses, sometimes by the hour.
"What's happening is that the market is watching the president and his team and the president is watching the markets," said Marina Severinovsky, an investment strategist at Schroders.
Severinovsky said the Trump administration doesn't want to derail the economy or the stock market and is sensitive to the way investors react to the ongoing trade disputes. Lately they've sent stocks lower, but if the market rallies in response to some strong second-quarter reports next month, she said the Trump team might feel encouraged to take tougher positions in trade talks.
The S&P 500 index added 16.68 points, or 0.6 percent, to 2,716.31. The Dow Jones Industrial Average rose 98.46 points, or 0.4 percent, to 24,216.05. The Nasdaq composite gained 58.60 points, or 0.8 percent, to 7,503.68. The Russell 2000 index of smaller-company stocks picked up 4.56 points, or 0.3 percent, to 1,645.02.
Amazon shook up multiple industries Thursday after it said it's buying online pharmacy PillPack, which offers pre-sorted dose packaging and home delivery. Investors expected Amazon to use its muscle to reduce costs and drug prices, and that led to sharp losses for drugstores, pharmacy benefits managers and companies that distribute medications.
Amazon rose 2.5 percent to $1,701.45 while Walgreens fell 9.9 percent to $59.70, and medication distributor Cardinal Health shed 4.8 percent to $50.37. Pharmacy benefits manager Express Scripts dipped 1.4 percent to $77.62.
Amazon also announced a new program under which contractors around the country can launch businesses that deliver Amazon packages, meaning Amazon will have new ways to deliver products without relying on companies like UPS and FedEx. UPS lost 2.3 percent to $105.88 and FedEx declined 1.3 percent to $226.67.
Benchmark U.S. crude continued to surge and gained 0.9 percent to $73.45 a barrel in New York. It's at its highest price since November 2014. Brent crude, used to price international oils, rose 0.3 percent to $77.85 a barrel in London.
Oil prices have rallied over the last week. First, investors concluded that OPEC countries will not increase oil production by as much as they feared. Then the U.S. started pressuring countries to stop importing oil from Iran, the world's sixth-largest producer of oil. The Trump administration is threatening other countries, including close allies such as South Korea, with sanctions if they don't cut off Iranian imports by early November, essentially erecting a global blockade.
BJ's Wholesale Club jumped after the company went public again. The stock started trading at $17 a share, at the high end of the company's projections, and then advanced 29.4 percent to $22. BJ's was taken private in 2011.
Madison Square Garden Co. jumped 13 percent to $303.29 after it said it will consider spinning off its sports division, which owns the NBA's New York Knicks and the NHL's Rangers, into a separate publicly traded company.
Still, trade concerns are a major reason the market is having a downbeat finish to the second quarter. The S&P 500 is down 2.4 percent in the last two weeks, trimming its gain for the quarter to 3 percent. The Dow is up just 0.5 percent.
The volatility may worsen at the beginning of the third quarter, as the U.S. is set to impose a 25 percent tariff on billions of dollars of Chinese products starting July 6. In response, China will raise import duties on $34 billion worth of American goods.
Bond prices edged lower. The yield on the 10-year Treasury note rose to 2.84 percent from 2.83 percent.
The dollar rose to 110.64 yen from 110.20 yen. The euro slipped to $1.1555 from $1.1557.
In other commodities trading, gold lost 0.4 percent to $1,251 an ounce. Silver fell 1.2 percent to $16.04 an ounce. Copper shed 1.2 percent to $2.97 a pound.
Wholesale gasoline was unchanged at $2.13 a gallon. Heating oil remained at $2.18 a gallon. Natural gas fell 1.4 percent to $2.94 per 1,000 cubic feet.
Germany's DAX was down 1.4 percent France's CAC 40 shed 1 percent. Britain's FTSE 100 lost 0.1 percent. Japan's benchmark Nikkei 225 index remained almost flat and South Korea's Kospi lost 1.2 percent. Hong Kong's Hang Seng added 0.5 percent.