NEW YORK (AP) -- U.S. stocks ended back where they started Friday as the stock market wrapped up its best quarter in almost five years. Electric car maker Tesla plunged after federal regulators moved to oust CEO Elon Musk following his tweet last month saying that he was close to a deal to take Tesla private.
Health care companies did better than any part of the market during the third quarter and they continued to rise Friday, while technology companies rose as chipmakers also traded higher. Facebook said it discovered a security breach in which 50 million accounts were accessed by unknown attackers, and its stock fell again, ending its worst quarterly run in six years.
Global banks fell and European stocks skidded after Italy's new government announced a big increase in spending. Italy's main stock index fell almost 4 percent as investors worried that the government's plan will lead to a clash with European Union leaders who want Italy to reduce its debt level.
Through the third quarter, pain in other markets led to gains for U.S. stocks, and that was true again Friday. The S&P 500 rose 7.2 percent, its biggest increase since the end of 2013.
One reason is that investors are worried about other regions, especially emerging markets. The currencies of Turkey and Argentina both dropped during the quarter and investors worried that their currency and economic problems would harm the rest of the world.
"Investors do pivot to the U.S. when they have concerns about other regions," said Marina Severinovsky, an investment strategist at Schroders. But emerging markets stocks have bounced back somewhat over the last two weeks, and Severinovsky said they might do better than U.S. stocks in the fourth quarter.
"The pessimism around those regions is probably too much," she said.
The S&P 500 index inched down 0.02 points to 2,913.98. The Dow Jones Industrial Average rose 18.38 points, or 0.1 percent, to 26,458.31. The Nasdaq composite added 4.38 points, or less than 0.1 percent, to 8,046.35. The Russell 2000 index of smaller-company stocks gained 6.04 points, or 0.4 percent, to 1,696.57.
The spending plans announced by Italy's new government would expand its budget deficit. European Union leaders want Italy to bring down its debt level, which is the highest of any EU country after Greece.
Italy's FTSE MIB sank 3.7 percent while the German DAX gave up 1.5 percent. France's CAC 40 lost 0.8 percent and the FTSE 100 index in Britain shed 0.5 percent.
Yields on Italian government bonds rose sharply, a sign of lower investor confidence in the government's financial strength. The yield on Italy's 10-year bond jumped to 3.14 percent from 2.89 percent, a huge move.
Italian bank UniCredit sank 6.7 percent to $12.96. Among European banks, Barclays dipped 3.6 percent to $8.95. In the U.S., Goldman Sachs shed 1.5 percent to $224.24.
Tesla suffered its worst loss in almost five years. It dropped 13.9 percent to $264.77 after the Securities and Exchange said Musk committed securities fraud with his statement about taking Tesla private. The SEC launched an investigation after Musk tweeted that he had secured the funding for his transaction, but it soon became clear that the company wasn't close going private.
Musk called the action unjustified. His tweet said the company would go private at $420 per share, and the stock jumped to almost $380 that day. It's fallen 31 percent since then.
Facebook fell 2.5 percent to $164.52 after it disclosed the breach. That capped a brutal three months for social media companies. Facebook plunged 19 percent on July 26 after it said user growth had slowed, a drop that slashed Facebook's value by $119 billion, its biggest one-day loss as a public company.
Facebook fell 15 percent in the third quarter and Twitter dropped 35 percent, more than any other S&P 500 stock. Twitter was on a huge run until July 27, when it, too, it reported weak user growth. Investors also worried about the possibility of greater regulation of both companies following hearings in Congress.
"In the U.S. and Europe these companies have largely been allowed, as they've grown to the size and scale and influence that they have, to self-regulate," said Severinovsky, of Schroders. "I think that era is over."
Japan's Nikkei 225 jumped 1.4 percent after the country agreed to open negotiations on a trade agreement with the United States. The move won Japan relief from the immediate threat of punitive tariffs on its auto exports to the U.S. Hong Kong's Hang Seng index added 0.3 percent and South Korea's slipped 0.5 percent.
Energy companies rose as benchmark U.S. crude rose 1.6 percent to $73.25 per barrel in New York. Brent crude, used to price international oils, added 1.2 percent to $82.72 per barrel in London.
Gold rose 0.7 percent to $1,196.20 an ounce. Silver jumped 3 percent to $14.71 an ounce. Copper gained 0.8 percent to $2.81 a pound.
Wholesale gasoline added 0.9 percent to $2.10 a gallon. Heating oil rose 1.2 percent to $2.35 a gallon. Natural gas fell 1.6 percent to $3.01 per 1,000 cubic feet.
Bond prices were little changed. The yield on the 10-year Treasury note stayed at 3.05 percent.
The dollar rose to 113.58 yen from 113.42 yen. The euro fell to $1.1610 from $1.1658.