NEW YORK — U.S. stocks shrugged off early losses and wound up with a mixed finish Monday. Household goods companies took some of the worst losses as the S&P 500 index fell for the third time in four days.

The S&P 500 dropped as much as 22 points early on. Consumer products and packaged foods companies stumbled and drug makers and distributors fell, as did health insurers. That came after indexes in Europe and Asia fell. German stocks took steep losses as investors wondered if a dispute over migrants could eventually threaten the German government.

But stocks gradually recovered most of their losses as energy companies rose along with oil prices and technology companies managed to make some gains as well. Smaller and more U.S.-focused companies climbed higher. That continued a pattern that has persisted for more than three months.

It’s been a turbulent few months for stocks, but the benchmark S&P 500 is a bit higher than it was when international trade tensions started to weigh on the market in late February. Terry Sandven, chief equity strategist at U.S. Bank Wealth Management, said it’s a good sign that some sectors that struggled are now doing better.

“It’s indicative of a market that’s unconvinced that a trade war will develop,” he said. Still, he said the next month of trading could be choppy as investors analyze the latest trade developments and wait for companies to start reporting their second-quarter results in mid-July.

The S&P 500 fell 5.91 points, or 0.2 percent, to 2,773.75. The Dow Jones industrial average dropped 103.01 points, or 0.4 percent, to 24,987.47. The Nasdaq composite edged up 0.65 points to 7,747.03.

The Russell 2000 index rose 8.55 points, or 0.5 percent, to a record 1,692.46. Many investors feel the smaller and more U.S.-focused companies in that index are less vulnerable in the event that a major trade dispute slows growth in the global economy. Most of the companies listed on the New York Stock Exchange closed higher.

Drugmaker Biogen suffered the biggest fall of any S&P 500 company following positive clinical trial results from a competitor. PTC Therapeutics jumped 27.5 percent to $47.88 after its report from an early study of a drug intended to treat Type 1 spinal muscular atrophy, a genetic disorder in infants. PTC’s drug could affect sales of Biogen’s Spinraza, and Biogen lost 5.2 percent to $289.12. Its partner Ionis Pharmaceuticals sank 6.4 percent to $43.61.

The German DAX fell 1.4 percent, and all 30 stocks on the index ended with losses. The CAC 40 in France lost 0.9 percent and Britain’s FTSE 100 fell less than 0.1 percent.