A spurt in oil prices Monday revived energy stocks, which have been among the year's worst performers, and helped push the broader market back to record highs.
The Standard & Poor's 500 index climbed 11.42 points, or 0.5%, to 2,402.32, edging above the record it set last week.
The Dow Jones industrial average rose 85.33 points, or 0.4%, to 20,981.94, the Nasdaq composite advanced 28.44, or 0.5%, to 6,149.67 and the Russell 2000 index of smaller stocks went up 11.15 points, or 0.8%, to 1,393.92.
Energy stocks helped lead the way after the price of oil jumped on expectations that the global glut of crude may ease.
A wide group of oil-producing countries has already cut production in hopes of supporting the price of oil, and Russia and Saudi Arabia said they want to extend the cuts through the first three months of 2018. Benchmark U.S. crude rose $1.01, or 2.1%, to settle at $48.85 a barrel. Brent crude, the international standard, rose 98 cents to $51.82 a barrel.
The price of oil has swung sharply in recent years, from more than $100 three years ago to less than $30 last year, as concerns wax and wane that supplies will overwhelm demand.
Monday's rise for crude helped oilfield services provider Halliburton jump $1.37, or 3%, to $46.51 for one of Monday's biggest gains in the S&P 500. Energy companies across the index rose 0.6%.
Companies that produce metals and other basic materials, along with financial stocks, were also strong.
Snap jumped 8% to $20.74 after regulatory filings showed that at the end of March, Fidelity and BlackRock held shares in the maker of the Snapchat app.
The day's rally continued a calm push higher for stocks in recent weeks. Markets around the world have been making modest, methodical gains as investors shrug off a long list of potential concerns.
South Korean stocks rose Monday even after North Korea launched a missile over the weekend and its leader promised more missile tests.
The worldwide "ransomware" cyberattack continued to spread, which sent cybersecurity stocks higher; FireEye leaped 7.5% to $15.90, and Symantec rose 3.2% to $32.
Meanwhile, politicians in Washington wonder whether Republicans' odds of implementing tax cuts and other pro-business policies have diminished.
For the most part, signs of a strengthening global economy and improving corporate profits have been enough to allay investors' fears and push markets to new heights. Profits have been rallying not only in the United States but also in Europe and other areas that had been struggling for years.
The recent run of calm is a sharp turnaround since the start of last year, when twitchy investors were quick to sell on worries about the global economy.
"We do really see this prevailing sense of complacency," said Jon Adams, senior investment strategist at BMO Global Asset Management. "I don't think we see any dark clouds on the horizon, but I wouldn't be surprised to see a 5 to 10% drawdown from now to year-end."
Adams expects corporate profits to keep improving, which should help support stocks, but he points to several events that could jolt markets. Besides the uncertainty about what will happen on the Korean peninsula or in Washington, upcoming elections in Britain, France and potentially Italy could also upset what's become a lazy ride for markets.
In Europe, France's CAC 40 rose 0.2%, while Germany's DAX index and the FTSE 100 in London each rose 0.3%. In Asia, Japan's Nikkei 225 stock index slipped 0.1%, Hong Kong's Hang Seng index jumped 0.9% and South Korea's Kospi index rose 0.2%.
In the commodities markets, the price of gold rose $2.30 to settle at $1,230 an ounce, silver rose 20 cents to $16.60 an ounce and copper rose 2 cents to $2.54 a pound.
Natural gas fell 8 cents to $3.35 per 1,000 cubic feet, heating oil rose 2 cents to $1.51 a gallon and wholesale gasoline rose 2 cents to $1.60 a gallon.
The euro rose to $1.0978 from $1.0924. The dollar rose to 113.68 yen from 113.41 yen, and the British pound rose to $1.2895 from $1.2879.
The 10-year Treasury yield ticked up to 2.34% from 2.33%. The two-year yield rose to 1.30% from 1.29%, and the 30-year yield rose to 3.01% from 2.99%.
4:05 p.m.: This article was updated with closing prices, context and analyst comment.
1:25 p.m.: This article was updated with the close of markets.