A last-minute surge nudged U.S. stock indexes mostly higher Thursday, barely extending the market's winning streak and milestone-setting run.
The Standard & Poor's 500 index and Dow Jones industrial average closed higher for the fifth straight day, each posting new highs. The other indexes finished slightly lower as investors continued to pore through the latest batch of company earnings.
Technology companies weighed on the market all day, but gains in health care stocks helped offset some of those losses.
"You have a lot of risk assets, especially equities, having done pretty well," said Sameer Samana, global quantitative strategist for Wells Fargo Investment Institute. "Some people are viewing now as a pretty good time to make sure they lock in some of that performance."
The S&P 500 index rose 0.84 points, or 0.03 percent, to 2,562.10. The Dow added 5.44 points, or 0.02 percent, to 23,163.04. The Nasdaq composite slid 19.15 points, or 0.3 percent, to 6,605.07. The Russell 2000 index of smaller-company stocks gave up 3.10 points, or 0.2 percent, to 1,502.04.
Slightly more stocks rose than declined on the New York Stock Exchange.
Investors bid up shares in drug manufacturers and other health care companies.
Envision Healthcare led the sector, vaulting $4.43, or 10.9 percent, to $45.08. Gilead Sciences rose $1.58, or 2 percent, to $81.59. A subsidiary of the drugmaker received approval this week to sell a new treatment for a form of blood cancer.
Medical equipment maker Danaher jumped 4.7 percent after it reported earnings that beat financial analysts' estimates and raised its outlook. The stock added $4.05 to $90.10.
Verizon Communications' latest quarterly results also impressed traders. The company said its wireless unit gained more mobile phone users than expected in its latest quarter. Its stock rose 56 cents, or 1.2 percent, to $49.21.
Adobe Systems surged 12.2 percent after the software maker issued a strong profit forecast for 2018. The stock was the biggest riser in S&P 500, climbing $18.73 to $171.73.
Other technology stocks didn't fare as well.
Apple had its worst day in two months amid investor concern that its recently launched iPhone 8 models are lagging in market share compared to prior iPhone models. The stock finished down $3.78, or 2.4 percent, at $155.98. Despite the slide, Apple is still up 34.7 percent this year.
The slide in Apple and other technology companies weighed on the market for much of the day. The sector, which is leading all other sectors in the S&P 500 with a gain of 30 percent this year, recovered some of its losses by late afternoon.
"The sector has had such a great run, but you're starting to see some concerns about how big they've gotten, some chatter in Washington about should there be some regulations," said Samana. "People are just content to take some money off the table."
While many more companies will be reporting third-quarter results in coming weeks, so far earnings have been largely positive. Some 75 S&P 500 companies have reported quarterly results so far, posting sales growth of about 6 percent and earnings gains of about 9 percent, Samana said.
Even so, quarterly report cards and outlooks from several companies failed to impress investors Thursday.
United Continental sank 12.1 percent after the parent of United Airlines said that weak prices will continue the rest of this year. The stock was the biggest decliner in the S&P 500, tumbling $8.21 to $59.78.
Auto parts retailer Genuine Parts slumped 8.5 percent after the company said costs rose and its quarterly profit fell short of Wall Street's estimates. The stock lost $8.33 to $89.71.
Bond prices rose. The yield on the 10-year Treasury note fell to 2.31 percent from 2.35 percent late Wednesday.
Benchmark U.S. crude lost 75 cents, or 1.4 percent, to settle at $51.29 per barrel on the New York Mercantile Exchange. Brent crude, used to price international oils, fell 92 cents, or 1.6 percent, to $57.23 per barrel in London.
The slide in oil weighed on energy stocks. Schlumberger declined $1.41, or 2.1 percent, to $64.50.
In other energy trading, wholesale gasoline was little changed at $1.64 a gallon. Heating oil slipped 3 cents to $1.78 a gallon. Natural gas gained 2 cents to $2.87 per 1,000 cubic feet.
Gold rose $7 to $1,290 an ounce. Silver added 26 cents to $17.26 an ounce. Copper lost 1 cent to $3.17 a pound.
The dollar fell to 112.65 yen from 112.90 yen on Wednesday. The euro rose to $1.1830 from $1.1802.
Global stocks mostly declined Thursday following relatively weak Chinese economic growth data and rising tensions over Catalonia's bid for independence from Spain.
In Europe, Germany's DAX declined 0.4 percent, while France's CAC 40 fell 0.3 percent. Britain's FTSE 100 slid 0.3 percent. Asian markets finished mostly weaker. Japan's Nikkei 225 gained 0.4 percent, while South Korea's Kospi slipped 0.4 percent. Hong Kong's Hang Seng index slumped 1.9 percent.