Miners and other companies dealing in commodities helped pull the stock market out of a three-day slump on Thursday.
News that China's trade rebounded last month signaled the end of a six-month slowdown for the world's biggest buyer of raw materials. The report drove prices up for copper and other commodities, and that helped lift Newmont Mining, Freeport-McMoRan and other stocks in the materials industry.
"The one thing that stands out today is the better news out of China," said David Joy, the chief market strategist at Ameriprise Financial. "It comes as a pleasant surprise."
The Standard & Poor's 500 index edged up 6.57 points, or 0.4 percent, to 1,697.48.
With little other news to drive trading, the stock market had meandered lower this week. The S&P 500 index fell three days straight and remains down 0.7 for the week. It's still up 19 percent this year.
Brad McMillan, chief investment officer for Commonwealth Financial Network in Waltham, Massachusetts, said a number of concerns have weighed on the market this week. Comments from Federal Reserve officials have convinced many investors that the bank will begin pulling back its support for the economy in the coming months.
At the same time, companies are warning of slower sales and turning in tepid second-quarter results. McMillan said it's starting to look like corporate earnings haven't kept up with the stock market's strong pace this year.
"I think people are realizing that stock values are getting disconnected from earnings growth," McMillan said. "For the rally to continue, people will have to pay more for earnings that aren't growing that much."
Investors are paying more for profits. A year ago, the price-earnings ratio for the S&P 500 was 13.4, according to the data provider FactSet. Now it's 15.6, which is still near the long-run average.
Snack giant Mondelez International, the maker of Oreo cookies, turned in better quarterly results than Wall Street had expected late Wednesday. The company also announced plans to spend another $5 billion buying its own stock. Mondelez International gained $1.44, or 5 percent, to $32.70.
Tesla Motors jumped 14 percent following news that the maker of electric cars blew past Wall Street's profit forecasts for its most recent quarter. Revenue soared thanks to stronger sales of its Model S. Tesla gained $19.25 to $153.48.
In economic news, the government reported that the average number of people who applied for unemployment benefits over the past four weeks dropped 6,250 to 335,500. That's the lowest level since November 2007, a month before the Great Recession got underway.
Gradual but steady gains for the U.S. economy and corporate profits have lifted the stock market to record territory this year. The S&P 500 index closed at an all-time high of 1,709.67 on Friday.
In other Thursday trading, the better economic news out of China sent copper, widely used for electronics and to wire buildings, up 10 cents, or 3 percent, to $3.27 a pound. Gold rose $24.60, or 2 percent, to $1,309.90 an ounce.
The yield on the 10-year Treasury note fell to 2.58 percent from 2.60 percent late Wednesday.
Among other companies in the news:
— Newmont Mining rose $2.30, or 9 percent, to $28.78 and Freeport-McMoRan Copper & Gold rose $1.37, or 5 percent, to $30.80. Mining companies rose broadly along with prices for commodities such as copper.
— JPMorgan Chase lost 47 cents, or 1 percent, to $54.83, after the bank said it's facing a criminal investigation tied to mortgage-backed bonds.