U.S. stocks rose on Wednesday, capping off a strong start to 2018. The Dow Jones industrial average and S&P 500 notched their best monthly performances since March 2016.

The Dow gained 72.5 points to close at 26,149.39, with Boeing rising 4.9 percent and hitting an all-time high. The rose 0.1 percent and finished at 2,823.81, with real estate as the best-performing sector. The Nasdaq composite advanced 0.1 percent to close at 7,411.48.

For the month, the Dow and S&P 500 posted gains of 5.6 percent and 5.8 percent, respectively. The Nasdaq meanwhile, rose 7.3 percent for the month, its best monthly gain since October 2015.

The major indexes briefly turned negative Wednesday after a statement from the Federal Reserve sent interest rates higher.

"The combination of the Fed and the fact that people want to book an awesome month could've taken us lower" earlier in the session, said Jeremy Klein, chief market strategist at FBN Securities.

The Fed left rates unchanged, but said it expects inflation to move "up this year and to stabilize" around its 2 percent target. Treasury yields rose on the back of the statement. The benchmark 10-year yield rose to 2.75 percent, before trading at 2.72 percent, while the two-year yield held around 2.15 percent.

"The statement is pretty consistent with what we've seen in the underlying data," said Erik Schiller, senior portfolio manager at PGIM Fixed Income. "It was a slightly hawkish statement, in our view."