Early rally in stocks is mostly gone by the closing bell

The Federal Reserve's latest signals on interest rates gave U.S. stocks a lift for much of Wednesday, but the rally didn't last.

A sell-off in the final minutes of trading knocked the Dow Jones industrial average and the Standard & Poor's 500 index slightly into the red. The slide extended a three-day losing streak for the two indexes. Only the Nasdaq composite held its course, carving out a slight gain.

Materials and energy stocks were among the biggest decliners as U.S. crude oil prices declined again.

Investors were mostly focused on Fed Chair Janet Yellen's remarks on the economy and interest rates as she delivered her semiannual report to Congress.

The Dow fell 99.64 points, or 0.6 percent, to 15,914.74. The average is now down 8.7 percent this year. The S&P 500 index slipped 0.35 point, or 0.02 percent, to 1,851.86. The index is off 9.4 percent this year.

The Nasdaq added 14.83 points, or 0.4 percent, to 4,283.59. The gain helped trim the Nasdaq's losses for the year, which stand at 14.5 percent.

Investors appeared to be in a buying mood early in the day in anticipation of Yellen's testimony. That sent stocks higher early on and sustained them until the last-minute slide as oil prices closed lower.