(AP) -- Stocks closed slightly lower on Wall Street Wednesday after an early rally fueled by optimism over the next round of trade talks between the U.S. and China lost momentum toward the end of the day.
The wobbly finish extended the S&P 500 index's losing streak to a fourth straight day, though the market is still on track to end the month with solid gains.
Losses in health care stocks, consumer goods makers and utilities offset solid gains in technology sector companies.
Stocks climbed in the morning after U.S. Treasury Secretary Steven Mnuchin told CNBC that a trade deal between the two nations was "about 90%" done during recent negotiations. President Donald Trump and Chinese President Xi Jinping are scheduled to meet at the G-20 summit this weekend and investors hope that talks will yield progress toward an agreement to resolve the costly trade war.
Initial optimism over the possibility of progress on trade helped drive up shares in technology stocks, particularly chipmakers. The sector is especially vulnerable to trade disruptions with China, the world's second largest economy.
The rally began to fade by midafternoon, however, as other sectors piled up losses.
"The market has pulled back its expectations in terms of when an agreement will be signed and is just focusing on whether or not they can continue on a viable path toward constructive negotiations," said Quincy Krosby, chief market strategist at Prudential Financial.
The S&P 500 index dropped 3.60 points, or 0.1%, to 2,913.78. The Dow Jones Industrial Average fell 11.40 points, or less than 0.1%, to 26,536.82. The index had been up as much as 111 points.
The Nasdaq composite, heavily weighted with technology stocks, gained 25.25 points, or 0.3%, to 7,909.97. The Russell 2000 index of smaller company stocks fell 3.26 points, or 0.2%, to 1,517.78.
The market is on track to end June with solid gains that have reversed most of the losses from a big sell-off in May. Investors pushed stocks higher through much of this month as they welcomed indications from the Federal Reserve that it will cut interest rates to keep the economy growing. The trend sent the benchmark S&P 500 index to an all-time high last week.
Worries of an economic slowdown have also prompted traders to shift money into less risky assets, such as U.S. government bonds and gold, which is on track for a 7.8% gain this month.
The multiple trade disputes between the U.S. and other nations, most prominently China, remain the biggest source of uncertainty looming over Wall Street.
This week's G-20 meeting in Osaka, Japan, is the first opportunity Trump and Xi have had to discuss their differences on trade face-to-face since Trump said he was preparing to target the $300 billion in Chinese imports that he hasn't already hit with tariffs, extending them to everything China ships to the United States.
"The market does not want to see that they leave the G-20 meeting and there's no hope, no chance for negotiations," Krosby said.
The two sides are in a stalemate after 11 rounds of talks that have failed to overcome U.S. concerns over China's acquisition of American technology and its massive trade surplus. China denies forcing U.S. companies to hand over trade secrets and says the surplus is much smaller than it appears once the trade in services and the value extracted by U.S. companies are taken into account.
How the trade war develops could affect whether central banks move to support their economies. Fed Chairman Jerome Powell this week noted that the economic outlook has become cloudier since early May amid uncertainty over trade and global growth. The Fed and the European Central Bank have indicated they are open to cutting interest rates if needed.
Investors are worried the fallout from the tariffs could hurt global economic growth and corporate profits. Already, analysts are projecting that second quarter earnings for S&P 500 companies will be down 1.2%, according to FactSet.
"You're headed into earnings season and there are real questions about what is the second quarter story going to have been in the face of what's turning into a pretty tough environment," said Rob Haworth, senior investment strategist at U.S. Bank Wealth Management. "The unanswered question for us is: Are tariffs worse than people think or not? Is the Fed having to help out because things are a little worse than we expected?"
Health care stocks were the biggest drag on the market Wednesday, with drugmakers leading the way lower for the sector. Eli Lilly dropped 3.5% and Nektar Therapeutics slid 3.8%.
Consumer products companies were also big decliners. General Mills slumped after the packaged foods maker reported weak sales trends in North America. The stock was the biggest loser in the S&P 500, falling 4.5%.
Even after losing some strength, technology companies led the gainers. Micron Technology notched the biggest gain in the S&P 500 after the chipmaker forecast improved demand for smartphone chips the rest of the year. The stock jumped 13.3%. Other chipmakers also rose. Advanced Micro Devices climbed 3.7% and Nvidia gained 5.1%.
Energy stocks rose along with the price of U.S. crude oil. Hess gained 5.1% and ConocoPhillips added 5%.
Benchmark crude oil rose $1.55 to settle at $59.38 a barrel. Brent crude oil, the international standard, rose $1.44 to close at $66.49 a barrel.
The televised Democratic presidential candidate debates on Wednesday and Thursday evening may weigh on health care stocks.
Many of the candidates have been arguing for expanding Medicare to cover uninsured Americans of all ages or some other form of universal health care coverage that would run counter to the current private insurance market.
"If 'Medicare For All' does not get a lot of air time or if other candidates criticize the proposal, we think that will be a positive for the market," Raymond James analyst Chris Meekins wrote in a research note Wednesday.
Several health care providers were trading lower ahead of the first debate. UnitedHealth Group slid 1.7%, Anthem dropped 2.2% and Centene lost 3.5%.
Major stock indexes in Europe were mostly lower Wednesday.
In other commodities trading, wholesale gasoline rose 10 cents to $1.97 per gallon. Heating oil climbed 5 cents to $1.97 per gallon. Natural gas fell 2 cents to $2.29 per 1,000 cubic feet.
Gold rose $1.60 to $1,413.30 per ounce, silver rose 99 cents to $15.28 per ounce and copper fell 3 cents to $2.71 per pound.
The dollar rose to 107.83 Japanese yen from 107.12 yen on Tuesday. The euro weakened to $1.1370 from $1.1373.