Bond yields, which had been rising sharply for the last several days, pulled back, bringing relief to investors worried about higher interest rates.
The Standard & Poor's 500 index ended a four-day losing streak. the Dow Jones industrial average, however, ended with a small loss after being up for most of the day. That extended the Dow's string of losses to five, the longest of the year. The Dow was held back by weakness in Home Depot and Johnson & Johnson.
The mostly higher finish failed to shake the market out of a slump it's been in since early August, when investors became discouraged by poor corporate earnings and a sharp increase in interest rates. The Dow has lost 4 percent since hitting an all-time high on Aug. 2 and is headed for its worst month since May 2012.
The Dow fell 7.75 points, or 0.05 percent, to 15,002.99.
Small-company stocks rose far more than the rest of the market, a sign that investors are more comfortable taking on risk. The Russell 2000 index jumped 15.32 points, or 1.5 percent, to 1,028.57.
Best Buy and Urban Outfitters rose sharply, leading the retail sector higher.
Best Buy jumped $4.07, or 13.2 percent, to $34.80, the biggest gain in the S&P 500. The electronics retailer said it earned 32 cents per share in the last three months, much better than the 12 cents per share financial analysts expected. Most of the growth came from cutting costs and focusing on online sales.
Urban Outfitters jumped $3.27, or 8.2 percent, to $43.19. The Philadelphia-based teen retailer reported a 25 percent surge in second-quarter income as sales rose across nearly all its brands.
The better news from retailers was a respite for investors, who have spent the last week and a half getting disappointing earnings and sales outlooks from some of the nation's largest store chains. Wal-Mart, Macy's, Kohl's and Saks all cut their sales forecasts, raising worries that the American consumer might be cutting back.
"The fact that some of these retailers were giving mixed signals was somewhat disconcerting," said Phil Orlando, chief equity market strategist with Federated Investors.
It wasn't all good news in the retail sector, however. Barnes & Noble plunged 12.4 percent after the bookseller's first-quarter loss more than doubled and the company's chairman called off his offer to buy the company's stores. Excluding one-time items, Barnes & Noble lost 86 cents per share, more than the 81 cents Wall Street analysts had expected. Thestock fell $2.06 to $14.61.
In the bond market, the source of a lot of investor worries recently, yields declined modestly after nearly two weeks of increases. The yield on the benchmark U.S. 10-year Treasury note fell to 2.82 percent from 2.88 percent late Monday. It's still up sharply from its low of the year, 1.63 percent, reached in early May.
Bond yields are important because they are used to set interest rates on many kinds of loans, including mortgages. Investors have worried that a sharp rise in borrowing costs could disrupt the recovery in the U.S. economy.
The Federal Reserve has been buying $85 billion worth of bonds every month to keep interest rates low and encourage borrowing and hiring. Now that the economy appears to be on the mend, investors expect the Fed to cut back on its purchases as soon as its September policy meeting.
"We're not talking about the Fed pulling the plug on the economy here," Orlando said. "We're talking about the Fed looking to normalize bond yields because the economy is improving."
In commodities trading, the price of crude oil fell $2.14, or 2 percent, to $104.96 a barrel. Gold rose $6.90, or 0.5 percent, to $1,372.60 an ounce.
Among other stocks making big moves:
— TiVo rose 51 cents, or 5 percent, to $10.99 after the company announced a new line of digital video recorders to give television viewers more control over what they watch.
— LightInTheBox plunged $7.69, or 40 percent, to $11.58. The newly public, China-based online retailer's sales forecast for the current quarter fell short of Wall Street's expectations. The company's initial public offering of stock in June priced shares at $9.50 each.
— Medtronic fell $1.27, or 2.3 percent, to $52.83 after the medical device maker's revenue fell shy of what Wall Street analysts were expecting. The stock has surged 29 percent this year and is trading at a five-year high.