The stock market broke two days of losses on Wednesday with solid gains as investors piled into shares of banks and energy companies.

Stocks jumped from the start on a rise in the price of crude oil, with banks joining the rally after a strong report on the service sector suggested the Federal Reserve may raise interest rates soon. Banks can benefit when rates rise because it allows them to charge more for their loans. Bank of America rose 2 percent.

advertisement | advertise on newsday

The yield on government bonds rose again, and investors dumped phone and real estate companies, sending them down nearly 2 percent. Investors find them less attractive as a source of income relative to bonds when yields are rising.

The Dow Jones industrial average climbed 112.58 points, or 0.6 percent, to 18,281.03. The Standard & Poor’s 500 index gained 9.24 points, or 0.4 percent, to 2,159.73. The Nasdaq composite rose 26.36 points, or 0.5 percent, to 5,316.02.

The price of U.S. benchmark crude closed near $50 a barrel, its highest price since late June, after a U.S. government report said energy stockpiles shrank last week, a surprise to most analysts.

The yield on the 10-year Treasury note rose to 1.71 percent from 1.69 percent.