NEW YORK (Reuters) - U.S. stocks rose on Monday, boosted by technology shares and by defense companies, which gained after the United States and Saudi Arabia signed a multi-billion dollar arms deal.

Shares of General Dynamics GD.N, Raytheon RTN.N, and Lockheed Martin LMT.N all hit record highs early on but ended off those levels, with gains of between 0.6 percent and 1.6 percent. Boeing BA.N gave the Dow its biggest boost, ending up 1.6 percent at $183.67.

The S&P industrials index .SPLRCI rose 0.7 percent and the S&P 500 posted a third straight day of gains, further recovering from last week's selloff that was tied to worries about the outlook for U.S. President Donald Trump's domestic agenda.

Trump visited Saudi Arabia over the weekend and sealed $110 billion in deals. Riyadh will buy U.S. arms to help it counter Iran, with options running as high as $350 billion over 10 years.

It was his first foreign trip since taking office and one the White House hopes will shift the focus away from domestic controversies such as his firing of the former Federal Bureau of Investigation chief and investigations into his administration’s possible links to Russia.

“For investors that were concerned about that, this successful trip he’s had has kind of put those concerns on the back-burner,” said Bucky Hellwig, senior vice president at BB&T Wealth Management in Birmingham, Alabama.

“There’s still a lot of money on the sidelines. When the market goes down, many investors view it as an opportunity to buy the dip.”

Traders work on the floor of the New York Stock Exchange (NYSE) in New York, U.S., May 22, 2017. REUTERS/Brendan McDermid

While every sector but energy ended higher on the day, tech shares were the day's best performers, with Amazon AMZN.O, Microsoft MSFT.O and Apple AAPL.O among the biggest drivers in the S&P 500 and the Nasdaq.

The Dow Jones Industrial Average .DJI closed up 89.99 points, or 0.43 percent, to 20,894.83, the S&P 500 .SPX gained 12.29 points, or 0.52 percent, to 2,394.02 and the Nasdaq Composite .IXIC added 49.92 points, or 0.82 percent, to 6,133.62.

Volatility eased as stocks continued their recovery from last week.

The CBOE Volatility Index .VIX, the most widely followed barometer of expected near-term stock market volatility, has given up nearly all its gains from last week. It fell more than a point on Monday to end at 10.93.

A much stronger-than-expected earnings season has also helped investor sentiment. With results in from nearly all of the S&P 500 names, year-over-year first-quarter growth is now estimated at 15.3 percent, Thomson Reuters data showed.

“There’s fundamental support underlying the market from that,” Hellwig said.

Ford F.N was up 2.1 percent at $11.10 after the automaker named James Hackett as chief executive, responding to investors' growing unease about its stock price and prospects.

Advancing issues outnumbered declining ones on the NYSE by a 2.17-to-1 ratio; on Nasdaq, a 1.95-to-1 ratio favored advancers.

The S&P 500 posted 45 new 52-week highs and 3 new lows; the Nasdaq Composite recorded 102 new highs and 60 new lows.

About 5.9 billion shares changed hands on U.S. exchanges, below the 6.9 billion daily average for the past 20 trading days, according to Thomson Reuters data.