Wall Street capped 2017 with a loss, weighed down by a broad slide in light trading ahead of the New Year's holiday.
Technology companies, banks and health care stocks accounted for much of the market's decline. Energy stocks also fell, even as the price of U.S. crude oil surged to its highest level in more than two years.
Despite the downbeat end to the week, the U.S. stock market finished 2017 with its strongest year since 2013.
The Standard & Poor's 500 index, the broadest measure of the stock market, gained 19.4 percent for the year, more than double its gain in 2016. Including dividends, the total return was 21.8 percent, as of late Friday.
The Dow Jones industrial average ended the year with a 25.1 percent gain, setting 71 all-time highs along the way.
The Nasdaq composite notched the biggest gain, an increase of 28.2 percent, while the Russell 2000 index of smaller-company stocks closed out 2017 with a gain of 13.1 percent.
"It's been the year that surprised everybody," said J.J. Kinahan, chief market strategist at TD Ameritrade. "It was truly buy-on-the-dip, and that paid off better than anyone possibly expected."
On Friday, many investors opted to pocket some of their gains, especially in technology stocks, which led the market with a gain of 36.9 percent. Chipmaker KLA-Tencor was among the sector's big decliners, dropping $2.78, or 2.6 percent, to $105.07.
Traders also sold off health care and financials stocks, both of which rose 20 percent this year. Health care management company Centene fell $2.02, or 2 percent, to $100.88, while SunTrust Banks gave up 85 cents, or 1.3 percent, to $64.59.
"We've seen a little bit of a rotation from growth back to some of the more defensive names, so it's not surprising to see some ... redistribution to areas that generally haven't participated," said Eric Wiegand, senior portfolio manager for Private Wealth Management at U.S. Bank.
Friday's slide pulled the market lower for the week.
All told, the S&P 500 ended the day down 13.93 points, or 0.5 percent, to 2,673.61. The Dow dropped 118.29 points, or 0.5 percent, to 24,719.22. The Nasdaq fell 46.77 points, or 0.7 percent, to 6,903.39. The Russell 2000 index gave up 13.42 points, or 0.9 percent, to 1,535.51.
Oil and gas futures finished broadly higher Friday. Benchmark U.S. crude added 58 cents, or 1 percent, to settle at $60.42 per barrel on the New York Mercantile Exchange. That's the highest closing price of the year and the first time U.S. crude has finished above $60 a barrel since June 2015.
Brent crude, which is used to price international oils, gained 71 cents, or 1.1 percent, to $66.87 per barrel in London. The price of natural gas continued to rise in response to the harsh winter weather gripping a large swath of the U.S. It gained 4 cents, or 1.3 percent, to $2.95 per 1,000 cubic feet.
Despite the big gain in oil and gas prices, energy stocks were mixed. National Oilwell Varco rose 53 cents, or 1.5 percent, to $36.02, while Range Resources slid 55 cents, or 3.1 percent, to $17.06.
"Just like stocks right now, the futures have a pretty light volume," Kinahan said. "We need some real volumes for people to say, 'OK, this is real.'"
In other energy futures trading, wholesale gasoline rose a penny to $1.80 a gallon, while heating oil added 2 cents, or 1.1 percent, to $2.08 a gallon.
Gold added $12.10, or 0.9 percent, to $1,309.30 an ounce. Silver gained 22 cents to $17.15 an ounce. Copper slipped a penny to $3.30 a pound.
Bond prices rose. The yield on the 10-year Treasury fell to 2.41 percent from 2.43 percent late Thursday.
The dollar finished the year weaker for the first time since 2012. The ICE U.S. Dollar Index, which compares the value of the dollar to a basket of major currencies, declined nearly 10 percent this year, its biggest drop since 2003.
On Friday, the U.S. currency fell to 112.64 yen from 112.87 yen on Thursday. The euro strengthened to $1.2012 from $1.1952.
The price of bitcoin was down 1.1 percent to $14,263 as of 4:48 p.m. ET, according to the tracking site CoinDesk. Bitcoin futures on the Cboe Futures Exchange picked up 5.8 percent to $14,550. The virtual currency has been highly volatile in recent weeks, hitting a record high before sliding sharply last week.
Major stock indexes in Europe finished mixed Friday. Britain's FTSE 100 climbed 0.9 percent, hitting a record on the close of a shortened trading day. Germany's DAX and France's CAC 40 each declined 0.5 percent.
For 2017, Britain's notched a gain of 7.6 percent, while indexes in Germany and France closed the year with gains of 12.5 percent and 9.3 percent, respectively.
In Asia, most markets ended the day with modest gains. Japan's Nikkei 225 closed 0.1 percent lower, while Hong Kong's Hang Seng index gained 0.2 percent. For the year, the Nikkei posted a gain of 19.1 percent, while the Hang Seng finished with a gain of 36 percent.