U.S. stocks rallied Friday after a surprisingly strong report on the U.S. job market raised optimism about the economy.

The S&P 500 climbed 0.9% and got close to its all-time high set on Monday. The Dow Jones industrial average rose 341 points, or 0.8%, to set its own record, while the Nasdaq composite clambered 1.2% higher.

Leading the way were banks, airlines, cruise-ship operators and other companies whose profits can benefit the most from a stronger economy where people are working and better able to pay for things. Norwegian Cruise Line steamed 4.9% higher, JPMorgan Chase rose 3.5% and the small companies in the Russell 2000 index gained 1.5%.

Treasury yields soared in the bond market after the U.S. government said employers added 254,000 more jobs to their payrolls last month than they cut. That was an acceleration from August’s hiring pace of 159,000 and blew past economists’ forecasts.

Friday’s jobs report was so strong that it pushed traders to abandon bets that the Federal Reserve will deliver another larger-than-usual cut to interest rates at its next meeting. They’re now forecasting zero chance for a cut of half a percentage point, according to data from CME Group. Just a week ago, they were saying it was better than a coin flip’s chance.

Such diminished expectations for future cuts sent the yield on the two-year Treasury shooting up to 3.93% from 3.71% late Thursday. The 10-year yield jumped to 3.97% from 3.85%.

The forced rethink about how low rates will ultimately go hurt stocks of home builders, real-estate owners and other companies that benefit from easier mortgage rates.

D.R. Horton, PulteGroup and Lennar all sank at least 2.5% for three of the biggest losses in the S&P 500. Home Depot slipped 0.8% and was the biggest single reason the Dow lagged other indexes. During the day, the Dow went from an early gain of 300 points to a modest loss and back to a big gain.

All told, the S&P 500 rose 51.13 points to 5,751.07. The Dow gained 341.16 to 42,352.75, and the Nasdaq climbed 219.37 to 18,137.85.

Also Friday, some 45,000 dockworkers at East and Gulf coast ports returned to work after their union reached a deal to suspend its three-day strike until Jan. 15 to provide time to negotiate a new contract. That helped calm worries that a lengthy strike could have pushed up on inflation and dragged on the economy.

In the oil market, the price for a barrel of Brent crude, the international standard, rose 0.6% to $78.05 per barrel to bring its gain for the week to 9.1%. A barrel of benchmark U.S. crude rose 0.9% to $74.38, up from roughly $68 at the start of the week.

— Associated Press