NEW YORK — Strong gains for technology companies like software and chip makers helped lead U.S. stocks higher Monday. Defense contractors also climbed as the market continued to bounce back from a bout of turbulence last week.

Stocks rose for the third day in a row. Technology companies are closing in on all-time highs and continued to rise Monday, led by big names like Cisco Systems and Qualcomm.

Aerospace and defense companies rose after President Trump presided over a huge sale of military equipment to Saudi Arabia. Amazon led consumer-focused companies higher. Energy companies lagged even though oil prices continued their recent climb.

Sameer Samana, a strategist for Wells Fargo Investment Institute, said people continue to spend more money on personal electronics while businesses invest in automation and software to boost their productivity.

“In a low-growth environment, you’ve got to squeeze more out of every dollar of investment,” Samana said. At the same time, he said, some overseas markets have been stronger than expected this year.

The Standard & Poor’s 500 index jumped 12.29 points, or 0.5 percent, to 2,394.02. The Dow Jones industrial average added 89.99 points, or 0.4 percent, to 20,894.83. The Nasdaq composite gained 49.91 points, or 0.8 percent, to 6,133.62. The Russell 2000 index of smaller-company stocks picked up 9.81 points, or 0.7 percent, to 1,377.14.

The technology component of the S&P 500 index has soared 18 percent this year, almost three times as much as the broader S&P 500. On Monday chipmaker Qualcomm gained $1.61, or 2.8 percent, to $59.28 and Cisco Systems, which sells equipment such as routers, switches and software, rose 38 cents, or 1.2 percent, to $31.59. Adobe Systems picked up $2.42, or 1.8 percent, to $138.85 and design software maker Autodesk jumped $3.45, or 3.1 percent, to $113.36.

Both the S&P 500 and tech-heavy Nasdaq composite set records early last week before worries about growing political uncertainty in Washington, which could hamper Trump’s agenda of tax cuts and deregulation, knocked those indexes back from their highs. The Russell 2000 of smaller companies, which would benefit more than large ones from Trump’s proposals, is down 3 percent from the record it set a month ago.

Samana said he thinks stocks will become more volatile in the coming months, but not because of politics. Instead, he thinks stocks will break out of their unusual calm because the Federal Reserve and European Central Bank will pull back on the stabilizing measures they’ve used since the global financial crisis.

“If they both start to lay the groundwork for pulling back on the extraordinary stimulus, that’s probably the catalyst for a little bit more volatility,” he said.

Aerospace and defense companies climbed after Trump presided over a $110 billion sale of military equipment to Saudi Arabia. The agreement could expand to $350 billion over 10 years. Lockheed Martin climbed $4.24, or 1.6 percent, to $277.03 and Boeing gained $2.91, or 1.6 percent, to $183.67.

Amgen and its partner UCB said women who took their experimental osteoporosis drug Evenity were more likely to have serious cardiovascular problems than patients who took Fosamax, an older drug. The companies said that was a new safety concern and they no longer expect the Food and Drug Administration to approve Evenity this year. Amgen lost $3.49, or 2.2 percent, to $153.02.

Ford replaced CEO Mark Fields as it struggles to keep the traditional parts of its business running smoothly while it tries to remake itself as a nimble, high-tech automaker. In Fields’ three years as CEO, popular cars like the Fusion sedan became dated and Ford lagged competitors in bringing long-range electric cars to market. Ford’s new CEO is Jim Hackett, who has led Ford’s mobility unit for more than a year.

Ford added 23 cents, or 2.1 percent, to $11.10. The stock is down 8.5 percent this year.

U.S-based Huntsman and Swiss specialty chemicals maker Clariant are merging to create a company with a market value of $13.8 billion. The company will call itself HuntsmanClariant and Clariant shareholders will own 52 percent of the new company. Huntsman stock slid 56 cents, or 2.1 percent, to $26.15 and Clariant stock rose 3.4 percent in Switzerland.

Oil prices continued to rally. Benchmark U.S. crude oil added 40 cents to $50.73 a barrel in New York. Brent crude, used to price international oils, rose 26 cents to $53.87 a barrel in London.

Wholesale gasoline gained 1 cent to $1.66 a gallon. Heating oil rose 2 cents to $1.60 a gallon. Natural gas climbed 7 cents, or 2.3 percent, to $3.33 per 1,000 cubic feet.

Gold rose $7.80 to $1,261.40 an ounce. Silver jumped 40 cents, or 2.4 percent, to $17.19 an ounce. Copper rose 1 cent to $2.60 a pound.

Bond prices moved a bit lower. The yield on the 10-year Treasury note inched up to 2.25 percent from 2.24 percent.

The dollar declined to 111.20 yen from 111.38 yen. The euro rose to $1.1234 from $1.1207.

In Britain, the FTSE 100 gained 0.3 percent. The German DAX dipped 0.2 percent and France’s CAC lost a fraction of a percentage point. Japan’s market rose following strong trade data. The benchmark Nikkei 225 gained 0.5 percent while the South Korean Kospi jumped 0.7 percent. Hong Kong’s Hang Seng surged 0.9 percent.