(Reuters) - The S&P 500 ended barely higher on Tuesday while the Nasdaq managed to scratch out a new record as gains in big tech names countered energy declines.

The Dow Jones Industrial Average also hit an intraday all-time high just after the market opened, and the benchmark S&P 500 came close to yet another record high.

U.S. equities have rallied sharply after President Donald Trump’s election in November, spurred by hopes the Republican-led government will cut regulations and taxes and enact higher infrastructure spending.

However, investors have expressed concerns those polices could be put off as Trump focuses elsewhere such as on immigration.

“There is probably a bit of political risk that investors are trying to weigh right now,” said Chuck Carlson, chief executive officer at Horizon Investment Services in Hammond, Indiana.

“But outside of that, the story is a pretty good one for stocks in terms of it looks like the economy is continuing to grow, I think corporate profits have been pretty good, certainly enough to support higher prices.”

With more than half of the S&P 500 having reported results, fourth-quarter earnings are on track to have climbed 8.2 percent, which would be the best performance since the third quarter of 2014, according to Thomson Reuters I/B/E/S.

The Dow Jones Industrial Average .DJI rose 37.87 points, or 0.19 percent, to 20,090.29, the S&P 500 .SPX gained 0.52 points, or 0.02 percent, to 2,293.08 and the Nasdaq Composite .IXIC added 10.67 points, or 0.19 percent, to 5,674.22.

Energy .SPNY was the worst-performing S&P sector, falling 1.4 percent. Chevron's CVX.N 1.4-percent fall and Exxon's XOM.N 0.6-percent drop were among the biggest drags on the S&P.

Oil prices were pressured by growing gasoline stockpiles in the United States as evidence of a burgeoning revival in U.S. shale production could complicate efforts to reduce a supply glut.

“If we are going into a quarter or two of lower energy prices ... the story of improving earnings for the S&P 500, with the help of improving earnings in energy companies, may be suspect,” said Bucky Hellwig, senior vice president at BB&T Wealth Management in Birmingham, Alabama.

Tech stocks helped prop up the S&P. Apple AAPL.O rose about 1 percent and Google parent Alphabet GOOGL.O gained 0.9 percent. Consumer staples .SPLRCS were the best performing S&P group, rising 0.8 percent.

In corporate earnings news, Emerson Electric EMR.N shares rose 4.5 percent after the manufacturer reported a higher-than-expected profit.

Slideshow ( 6 images )

General Motors GM.N fell 4.7 percent after the automaker said that fourth-quarter net income fell partly on the strength of the dollar against the British pound and forecast flat 2017 profit per share.

Michael Kors KORS.N dropped 10.8 percent, after the handbag maker forecast current-quarter profit below estimates.

After the market closed, Walt Disney DIS.N shares fell following the company's quarterly report.

Slideshow ( 6 images )

About 6.6 billion shares changed hands in U.S. exchanges, slightly below the 6.7 billion daily average over the last 20 sessions.

Declining issues outnumbered advancing ones on the NYSE by a 1.21-to-1 ratio; on Nasdaq, a 1.40-to-1 ratio favored decliners.

The S&P 500 posted 32 new 52-week highs and 4 new lows; the Nasdaq Composite recorded 108 new highs and 40 new lows.