NEW YORK — U.S. stocks rallied for their fourth gain in a row Wednesday as banks climbed along with bond yields. On Wall Street there were signs investors were getting a bit less nervous about trade tensions.

Some of the biggest gains went to industries that have lagged the market in the last few months, including financial companies. Interest rates rose as bond prices in the U.S. and Europe fell. That can signal higher rates on mortgages and other consumer loans. Bank of America gained more than 3 percent.

Multinational companies such as Boeing and McDonald’s also rose. That helped the Dow Jones industrial average make its biggest gain in almost two months.

Worries about international trade disputes have been affecting the market since late February, but Karyn Cavanaugh, senior markets strategist at Voya Investment Management, said investors might have started focusing on the strength of the U.S. economy and continued global growth instead.

“It’s refreshing to see that investors are realizing this is an incredibly good economic backdrop and it’s an incredibly good environment for companies to make money,” she said. “We’re in a sweet spot where we have some growth and low inflation and investors just don’t want to believe it.”

The S&P 500 index added 23.55 points, or 0.9 percent, to 2,772.35. The Dow rose 346.61 points, or 1.4 percent, to 25,146.39. The Nasdaq composite rose 51.38 points, or 0.7 percent, to 7,689.24. The Russell 2000 index of smaller company stocks gained 11.32 points, or 0.7 percent, to 1,675.95. The Nasdaq and Russell have set all-time highs each of the last few days.

Electric car maker Tesla surged to its biggest gain in two and a half years as investors grow more confident it will meet its production targets for the Model 3 sedan. Tesla rose 9.7 percent to $319.50.

Chairman and CEO Elon Musk said he expects that the company will be able to produce 5,000 Model 3s in a single week by the end of this month.

Bond prices slipped Wednesdy. The yield on the 10-year Treasury note rose to 2.78 percent from 2.93 percent, and JPMorgan Chase climbed 2.3 percent to $110.36. Wells Fargo added 2 percent to $55.58.

Banks have fallen over the last few months even though long-term interest rates have reached their highest levels in years.

Health care and basic materials companies, which are essentially flat over the same period, did better than the rest of the market Wednesday. CVS Health rose 2.8 percent to $65.08 and chemical maker DowDuPont jumped 3.2 percent to $70.04.

That didn’t mean investors were ready to overlook trade issues altogether. Brown-Forman, the maker of Jack Daniel’s and other liquors, slumped 6.1 percent to $52.47. The company said it has concerns about how trade tensions might affect its business. On Tuesday, Mexico announced tariffs on bourbon and other U.S. products.