Stocks closed higher Thursday, with the three major indexes closing at new record highs, amid sharp gains in oil prices and strong quarterly results from retailers.

"I think there are two main drivers here. One of them is oil," said Mariann Montagne, senior investment analyst at Gradient Investments. "The other part is this retail rally."

Thursday also marked the first time since 1999 the Dow, S&P and the Nasdaq posted record closing highs on the same day, according to Bespoke.



The Dow Jones industrial average closed about 115 points higher, with 3M contributing the most gains. The 30-stock index also traded above a previous record high of 18,622.01.

The benchmark S&P 500 advanced about 0.5 percent, with energy rising more than 1 percent. The index also briefly traded above its previous all-time intraday high of 2,187.66.

"We have good things happening with the consumer right now," said JJ Kinahan, chief strategist at TD Ameritrade. he also said the positive quarterly results from Alibaba are helping the market, as they show the Chinese consumer is doing well. Alibaba's U.S.-listed shares were up 6.14 percent.

The Nasdaq composite rose about 0.5 percent as the iShares Nasdaq Biotechnology ETF (IBB) gained 1.07 percent.

"This has been a broad-based rally," said Bruce Bittles, chief investment strategist at Baird. "The market is following the broader trend, which is higher."

U.S. oil settled 4.27 percent higher at $43.49 a barrel on comments from the Saudi oil minister about possible action to stabilize prices and as the International Energy Agency forecast crude markets would tighten in the second half of 2016, a day after falling nearly 2.5 percent amid an unexpected build in inventories. "Oil is about stabilization," said Art Hogan, chief market strategist at Wunderlich Securities. "If we get that above $40, we're going to be OK."



Peter Cardillo, chief market economist at First Standard Financial, said "I think oil is going to stay in this $42-$45 range."