By Sam Forgione

NEW YORK (Reuters) - The S&P 500 and Dow U.S. stock indexes ended at fresh record highs on Wednesday even as a rally in U.S. and European shares lost much of its steam on a plunge in oil prices and caution ahead of corporate results.

The S&P 500 ended at 2,152.43, a hair above Tuesday's close of 2.142.14, to notch its third consecutive record close. The Dow ended at 18,372.12, topping Tuesday's close of 18,347.67 to mark its second straight record close.

In percentage terms, the S&P 500 ended nearly flat and the Dow was only slightly higher after a more than 4 percent plunge in oil prices hurt energy shares and investors awaited second-quarter corporate earnings. European shares dipped after four straight days of gains.

The S&P energy index ended down 0.71 percent and the STOXX Europe 600 Oil & Gas index ended 1 percent lower. The U.S. government stunned the market with bearish oil inventory data that added to renewed concerns over a global glut.

The benchmark S&P 500 hit 2,156.45 earlier on Wednesday, topping Tuesday's intraday record of 2,155.40, while the Dow hit 18,390.16 to top Tuesday's record intraday peak, the third straight day of such peaks for the S&P and the second for the Dow.

Shares have advanced partly on the view that the U.S. economy is on solid footing and on the expectation that central banks in most developed economies will continue to keep interest rates at rock-bottom levels. Reduced political uncertainty in Britain and Japan have also buoyed shares.

"Investors would rather see some concrete news as far as earnings and results before putting their money in at these levels," said Alan Lancz, president of investment advisory firm Alan B. Lancz & Associates Inc in Toledo, Ohio.

MSCI's all-country world equity index was last up 0.91 point, or 0.22 percent, at 409.3.

The Dow Jones industrial average ended up 24.45 points, or 0.13 percent, at 18,372.12. The S&P 500 closed up 0.29 point, or 0.01 percent, at 2,152.43. The Nasdaq Composite ended down 17.09 points, or 0.34 percent, at 5,005.73. [nL1N19Z1U3]

Europe's broad FTSEurofirst 300 index closed 0.31 percent lower at 1,326.30.

Brent crude settled down $2.21, or 4.56 percent, at $46.26 a barrel. U.S. crude settled down $2.05, or 4.38 percent, at $44.75.

"A surprising build in gasoline in the peak of the U.S. driving season and a very large build in heating oil will set the tone for lower prices," said Tariq Zahir, a trader in crude oil spreads at Tyche Capital Advisors in New York.

Safe-haven assets such as U.S. Treasuries, gold, and the Japanese yen rebounded after falling Tuesday. Benchmark 10-year Treasury yields were last at 1.473 percent after hitting a 1-1/2-week high of 1.531 percent on Tuesday as higher yields attracted buyers.

The dollar was last down 0.27 percent at 104.41 yen , while spot gold recovered slightly from its lowest in nearly two weeks.

(Additional reporting by Karen Brettell in New York and Yashaswini Swamynathan in Bengaluru; Editing by Nick Zieminski and James Dalgleish)