Wall Street closed out the final day of the second quarter with slight gains after a broad rally faded in the last few minutes of trading Friday.
The Dow Jones industrial average and the Standard & Poor's 500 index eked out tiny gains, while the Nasdaq composite closed essentially flat.
Industrial stocks and consumer-focused companies led the gainers. Energy stocks also rose as crude oil prices closed higher for the seventh straight day. Utilities, technology and health care companies were among the biggest decliners.
Trading was mostly subdued ahead of the Independence Day holiday next week, though many investors seized on the final trading day of the quarter and the previous day's market slide to buy more shares or close out positions and book profits.
"Overall we're ending this quarter with a strong market, even though technology has taken a hit, other sectors have moved up," said Quincy Krosby, chief market strategist at Prudential Financial.
The S&P 500 index rose 3.71 points, or 0.2 percent, to 2,423.41. The Dow gained 62.60 points, or 0.3 percent, to 21,349.63. The Nasdaq lost 3.93 points, or 0.1 percent, to 6,140.42. The Russell 2000 index of small-company stocks gave up 0.84 points, or 0.1 percent, to 1,415.36.
Bond prices fell. The 10-year Treasury yield rose to 2.30 percent from 2.27 percent late Thursday.
The major stock indexes got off to a shaky start early Friday, but soon veered higher and held course for much of the day. A last-minute flurry of selling nudged the Nasdaq and Russell 2000 slightly into the red.
The Dow, S&P 500 and Nasdaq ended the week in negative territory. This was also the worst week of the year for the Nasdaq and the third loss in the last four weeks for the tech-heavy index.
The market's snapshot at the halfway mark for 2017 is more encouraging, however.
The S&P 500 index, the broadest measure of the stock market, is up 8.2 percent this year, while the Dow is up 8 percent. The Nasdaq has racked up a gain of 14.1 percent. The Russell 2000 is up 4.3 percent.
Strong corporate earnings and revenue have underpinned the market's gains this year. Expectations among investors that President Donald Trump and the Republican-led Congress would slash taxes, boost federal spending on infrastructure and enact other business-friendly policies have also helped drive stocks higher.
Investors appeared to temper those expectations in recent weeks as the Trump administration hit legislative snags in its bid to pass a health insurance overhaul.
On Thursday, S&P Global Ratings noted that sentiment on Wall Street, which had been strong following Trump's election, has begun to soften.
"Now, we no longer believe the federal government will be able to push through even a small infrastructure-spending package, and we expect only moderate tax cuts to be passed early next year as midterm elections approach," wrote Beth Ann Bovino, S&P Global's U.S. chief economist.
Remarks from central bank officials in Europe earlier this week helped set the tone for the market, spurring speculation among investors that global interest rates could move higher. That sent bond yield sharply higher and helped lift shares in banks. Traders also sold off technology stocks. The sector had its worst week this year.
Even so, technology still leads all other sectors. It's up 16.4 percent this year, followed by health care and consumer discretionary stocks. Energy stocks are the biggest laggard at the midpoint of the year, down 13.8 percent. Phone companies are also in the red.
On Friday, investors sized up the latest company earnings and deal news.
The Commerce Department said consumer spending grew just 0.1 percent in May, less than the last couple of months. Personal income grew by a healthy 0.4 percent, but spending only rose 0.1 percent.
Athletic apparel maker Nike had its best day in almost two years Friday. Its shares jumped 11 percent after a strong quarterly report. Nike also said it's testing a program to sell sneakers directly through Amazon.com. Nike shares were the biggest gainer in the S&P 500, adding $5.83 to $59.
Specialty contractor Quanta Services was the biggest gainer in the industrials sector, rising $1.04, or 3.3 percent, to $32.92.
Parkway vaulted 12.3 percent after the Canada Pension Plan Investment Board agreed to buy the commercial real estate investment trust for about $1.13 billion. Parkway rose $2.51 to $22.89.
Hain Celestial climbed 8.6 percent after activist investor Engaged Capital disclosed a 9.9 percent stake in the organic food maker. Hain shares added $3.06 to $38.82.
American Outdoor Brands slid 7.4 percent after the firearms maker issued weak forecasts for the current quarter and the fiscal year. Shares in the company, which changed its name from Smith & Wesson earlier this year, fell $1.78 to $22.16.
Crude oil prices closed higher for the seventh straight day. Benchmark U.S. crude gained $1.11, or 2.5 percent, to settle at $46.04 a barrel in New York. Brent, the international standard, rose $1.14, or 2.4 percent, to close at $48.77 a barrel in London.
In other energy futures trading, wholesale gasoline picked up 4 cents to $1.51 per gallon. Heating oil added 3 cents to $1.48 per gallon. Natural gas was little changed at $3.04 per 1,000 cubic feet.
Among metals, gold fell $3.50 to settle at $1,242.30 per ounce. Silver slipped 3 cents to $16.63 per ounce. Copper gained 2 cents to $2.71 per pound.
The dollar rose to 112.54 yen from 112.07 yen late Thursday. The euro gave up some of its gains from earlier in the week. The euro weakened to $1.1422 from $1.1432. The pound rose to $1.3017 from $1.2991.
Major stock indexes in Europe closed lower Friday.
Germany's DAX and the CAC 40 in France each lost 0.7 percent. The FTSE 100 index of leading British shares slid 0.5 percent.
In Asia, trading was mixed. The Hang Seng in Hong Kong fell 0.8 percent, while Japan's Nikkei 225 index dropped 0.9 percent. South Korea's Kospi lost 0.2 percent, while Australia's S&P ASX 200 lost 1.7 percent. Shares in Southeast Asia were mostly lower.