(AP) -- Gains among technology companies helped snap a three-day losing streak for U.S. stocks Friday, though the market ended with its worst weekly loss since March.
The modest rebound came at the end of a turbulent week on Wall Street as escalating tensions between the U.S. and North Korea rattled global markets.
In the first four days of the week, the Standard & Poor's 500 index swung from marking its latest record high to posting its biggest single-day drop in nearly three months.
The negative headlines provided many investors with an opportunity to pocket some of their recent gains following a string of record highs fueled by strong corporate earnings.
"It's been a bit of a roller coaster this week, with all the rhetoric between the U.S. and North Korea," said Jeff Kravetz, regional investment strategist at U.S. Bank Wealth Management. "That did temporarily shake investors' complacency, but we think markets are ready to move higher in the back half of the year, and earnings and economic data are going to drive that."
On Friday, the S&P 500 rose 3.11 points, or 0.1 percent, to 2,441.32. The index had its biggest drop since mid-May a day earlier. The Dow Jones industrials average gained 14.31 points, or 0.1 percent, to 21,858.32. The Nasdaq added 39.68 points, or 0.6 percent, to 6,256.56. The Russell 2000 index of smaller-company stocks picked up 1.69 points, or 0.1 percent, to 1,374.23.
The recovery fit a recent pattern of investors using dips to put more money in stocks.
Despite the past week's decline, the major indexes are in positive territory so far this year, led by the Nasdaq, which is up 16.2 percent. The S&P 500 is up 9 percent, while the Dow is up 10.6 percent.
"If you strip away what's going on in North Korea, and if you strip away what's going on in Washington, which are things that are tougher to predict, the economy, the global recovery, earnings, it all paints a very positive picture for the rest of the year," Kravetz said.
Tensions between the U.S. and North Korea continued to simmer early Friday. In a tweet, President Donald Trump warned of military action "should North Korea act unwisely," noting that the U.S. is "locked and loaded." Earlier in the week, Trump said the U.S. would unleash "fire and fury" on North Korea if it continued to threaten the U.S.
North Korea had announced a detailed plan to launch a salvo of ballistic missiles toward the U.S. Pacific territory of Guam, a major military hub and home to U.S. bombers.
Still, there were fewer signs of anxiousness in the markets Friday. Bond and gold prices, traditional havens for nervous investors, were little changed, and the VIX, a measure of how much volatility investors expect in stocks, fell 3.3 percent following a 44.4 percent jump the day before. It's still the highest it's been since May.
Investors also drew some encouragement from new government data showing U.S. inflation at the consumer level inched higher last month. July's 0.1 percent increase in consumer prices suggests that the Federal Reserve may be less likely to raise interest rates next month.
Inflation has risen 1.7 percent over the past 12 months, suggesting that inflation pressures remain well under control. The Fed, which raised its key interest rate in March and June, has signaled it plans a third rate hike before the end of this year. But some economists say the Fed may stand pat for the rest of 2017 unless inflation accelerates in coming months.
"Today's inflation data put the Fed on pause and really diminishes the fact that there's still some noise going around with the North Korea-U.S. situation," said Phil Blancato, CEO of Ladenburg Thalmann Asset Management.
Technology companies, which suffered the brunt of the selling a day earlier, were back in the lead Friday. Lam Research Corp. climbed $4.82, or 3.2 percent, to $154.26.
Seagate Technology gained 2.3 percent after investor ValueAct disclosed that it had acquired a 7.2 percent stake in the digital storage company. Seagate shares rose 74 cents to $32.29.
Traders sold off financial stocks amid speculation that the Fed will decide to hold off on raising interest rates next month. Higher interest rates can help boost banks' revenue from loans. Regions Financial shed 23 cents, or 1.6 percent, to $14.07.
J.C. Penney sank 16.6 percent after the struggling department store chain reported quarterly results that fell short of Wall Street's expectations. The company also said sales at its established stores declined for the fourth straight quarter. The stock lost 78 cents to $3.93.
Bond prices rose. The yield on the 10-year Treasury note slipped to 2.19 percent from 2.20 percent late Thursday.
Benchmark U.S. crude rose 23 cents to settle at $48.82 a barrel on the on the New York Mercantile Exchange. Brent crude, used to price international oils, rose 20 cents to $52.10 a barrel in London.
In other energy futures trading, wholesale gasoline rose 1 cent to $1.61 a gallon, while heating oil was little changed at $1.63 a gallon. Natural gas was also flat at $2.98 per 1,000 cubic feet.
Gold added $3.90 to settle at $1,294 an ounce. Silver gained 1 cent to $17.07 an ounce. Copper rose 1 cent to $2.91 a pound.
The dollar slipped to 109.04 yen from 109.26 late Thursday. The euro rose to $1.1812 from $1.1774.
Major indexes in Europe closed mostly lower. Germany's DAX was flat, while France's CAC 40 fell 1.1 percent. Britain's FTSE 100 was down 1.1 percent.
In Asia, several indexes closed lower overnight. South Korea's Kospi lost 1.7 percent, while Hong Kong's Hang Seng slid 2 percent. Australia's S&P/ASX 200 dropped 1.2 percent. Japan was closed on a public holiday.