NEW YORK (AP) -- U.S. stock indexes nudged higher Friday after energy companies clawed back some of their sharp losses from earlier in the week.
After meandering up and down through the day, the Standard & Poor's 500 rose 3.80 points, or 0.2 percent, to end at 2,438.30. The Dow Jones industrial average slipped 2.53 points, or less than 0.1 percent, to 21,394.76, and the Nasdaq composite gained 28.56, or 0.5 percent, to 6,265.25. More than twice as many stocks rose than fell on the New York Stock Exchange.
Energy stocks led the way, and those in the S&P 500 climbed 0.8 percent for the largest gain of the 11 sectors that make up the index.
Rising prices for oil and natural gas drove the gains. Benchmark U.S. crude added 27 cents to settle at $43.01 per barrel. Brent crude, the international standard, gained 32 cents to $45.54 and natural gas rose 4 cents, or 1.2 percent, to $2.93 per 1,000 cubic feet.
EQT, a producer of natural gas and crude, had the day's biggest gain in the S&P 500 and jumped $4.16, or 8 percent, to $56.19. Cabot Oil & Gas climbed 88 cents, or 3.8 percent, to $23.74.
Friday's gains, though, weren't enough to keep energy stocks from closing out their worst week in nine months. They had earlier sunk four straight days as oil dropped to its lowest price since August on expectations that the world has more crude supplies than users need. Energy stocks lost 2.9 percent over the course of the week.
What kept broad indexes afloat for the week were big gains for health care and technology stocks. The S&P 500 rose 0.2 percent for the week.
Health care stocks climbed as the Senate unveiled its proposal to revamp how Americans get medical care. Technology companies, meanwhile, are forecast to report strong growth in the upcoming earnings season, and Oracle's profit report on Wednesday sailed past analysts' expectations.
"In terms of the overall market, what you really worry about with oil is what it does to earnings," said Steve Chiavarone, portfolio manager at Federated Investors. A big pickup in corporate profits has been one of the main reasons for the stock market's continued climbs this year, and energy companies had been forecast to provide some of the strongest growth in 2017.
With the price of oil about 15 percent below where it was a year ago, energy companies' profits may be at risk. But as long as oil's price can hold close to where it is, "that's good enough given that there's corporate profit growth everywhere else," Chiavarone said.
Friday's biggest decliner in the S&P 500 was Bed Bath & Beyond, which reported weaker earnings for the latest quarter than analysts expected. The retailer's revenue also fell short of Wall Street's forecasts. Its shares fell $4.09, or 12.1 percent, to $29.65.
Bond prices were little changed, and yields held relatively steady. The 10-year Treasury yield dipped to 2.14 percent from 2.15 percent late Thursday. The two-year yield was flat at 1.34 percent, and the 30-year yield held at 2.72 percent.
The dollar slipped to 111.26 Japanese yen from 111.34 yen late Thursday. The euro rose to $1.1199 from $1.1147, and the British pound rose to $1.2722 from $1.2672.
In European stock markets, France's CAC 40 fell 0.3 percent, Germany's DAX lost 0.5 percent and the FTSE 100 slipped 0.2 percent.
A monthly survey revealed that a measure of economic strength in the 19-country Eurozone slipped to a five-month low in June, which was below market expectations. However, the IHS Markit composite purchasing managers' index indicated that job creation and business confidence were still robust.
Japan's Nikkei 225 index added 0.1 percent, South Korea's Kospi rose 0.3 percent and the Hang Seng in Hong Kong was close to flat.
In the commodities market, gold rose $7.00 to settle at $1,256.40 ounce. Silver added 14 cents to $16.65 per ounce, and copper rose 3 cents to $2.62 per pound.
Heating oil was close to flat at $1.37 per gallon and wholesale gasoline was little changed at $1.43 per gallon.