A tumble in oil prices Wednesday prompted investors to sell shares of energy companies, weighing on the broader stock market.

Stocks had briefly pared losses to trade near the flatline after the minutes from the Federal Reserve’s July meeting showed no clear sign that officials are ready to raise interest rates next month.

Stocks have rallied...