Financial, industrial and health care stocks were among the big winners. Those sectors outweighed losses in consumer goods makers and communication services stocks. Shares in companies that rely on consumer spending also fell.
The stock indexes wavered between small gains and losses through much of the day, with trading volumes lighter than usual. "Going into a holiday weekend you just have three days here where you're not going to be able to reposition, so people are probably taking some profits and squaring their books ahead of the weekend," said Sameer Samana, senior global market strategist at Wells Fargo Investment Institute.
The S&P 500 edged up 1.88 points, or 0.1%, to 2,926.46. The Dow Jones Industrial Average rose 41.03 points, or 0.2%, to 26,403.28. The Nasdaq gave up an early gain, sliding 10.51 points, or 0.1%, to7,962.88. The Russell 2000 index of smaller company stocks dropped 1.88 points, or 0.1%, to 1,494.84.
The major indexes stemmed their August slide this week, but still ended the month with losses. The Dow dropped 1.7%, the S&P 500 lost 1.8% and the Nasdaq gave up 2.6%. The Russell took the heaviest losses for the month, falling 5.1%.
Trading turned volatile in August as investors worried that the escalating trade war between the U.S. and China and a slowing global economy could tip the U.S. into a recession. The bond market seemingly confirmed these fears when long-term bond yields fell below short-term ones, a so-called inversion in the U.S. yield curve that has correctly predicted previous recessions.
"We found the limits of how far both the U.S. and the Chinese side can push the trade issue until it actually starts to manifest itself in markets," Samana said. "And where you probably saw the bulk of that reaction is in the fixed-income market. That's why you saw long-term yields basically collapse."
Bond prices initially fell Friday, pushing yields higher, but then lost momentum. That pushed long-term bond yields further below short-term ones. The yield on the 10-year Treasury fell to 1.50% from 1.51% late Thursday. The 2-year Treasury yield dropped to 1.51% from 1.55% the day before.
Washington and Beijing are deadlocked in talks over U.S. complaints about China's trade surplus and industrial plans, which its trading partners say are based on stealing or pressuring companies to hand over technology.
Last week, the trade conflict escalated again with both sides threatening new tariffs on each other's goods, triggering a sharp sell-off in global markets. Some of the Trump administration's additional tariffs on Chinese products take effect Sunday and others on Dec. 15. In addition, higher tariffs on a separate group of Chinese products are to take effect Oct. 1.
Still, investors were encouraged by a Chinese government statement Thursday that its penalties on U.S. products are adequate. That suggested Beijing might be pausing in the tit-for-tat cycle of tariff increases that has raised fears the global economy might tip into recession.
Negotiators meet next month in Washington after the latest round of talks in July in Shanghai produced no sign of progress. Investors also weighed a mixed batch of corporate earnings reports Friday. Campbell Soup rose 3.9% and Big Lots added 3.4%. Both companies reported quarterly profits that easily beat analysts' forecasts. Ulta Beauty plunged 29.6%, it's biggest drop ever, after the company reported weak results and cut its estimates.
Benchmark crude oil fell $1.61 to settle at $55.10 a barrel. Brent crude oil, the international standard, fell 65 cents to close at $60.43 a barrel. Wholesale gasoline fell 7 cents to $1.61 per gallon. Heating oil declined 3 cents to $1.83 per gallon. Natural gas fell 1 cent to $2.29 per 1,000 cubic feet.
Gold fell $7.40 to $1519.10 per ounce, silver rose 2 cents to $18.19 per ounce and copper fell 3 cents to $2.53 per pound. The dollar fell to 106.25 Japanese yen from 106.62 yen on Thursday. The euro weakened to $1.0978 from $1.1052.
U.S. markets will be closed Monday for Labor Day.