U.S. stocks closed near highs on Thursday, with the Nasdaq at a record, as investors cheered corporate reports.
The Nasdaq Composite outperformed the major indices to set a new, all-time closing record, topping the previous high of 5,048.62 set in March 2000. (Tweet This)
"Earnings for the most part have come in better than expected," said Ryan Larson, head of U.S. equity trading for RBC Global Asset Management (U.S.). Despite headwinds from the strong dollar and low oil prices, companies have mostly delivered on expectations, which "has led credence to the U.S. market that we're able to move higher from here."
The economic data also points to moderate growth that supports gradual normalization by the Federal Reserve, Larson said. "That continues to lend credence back into the U.S. market for stocks."
Read MoreWake up! Stocks are breaking out
The S&P 500 closed up 4.97 points, or 0.24 percent, at 2,112.93, with telecommunications leading eight sectors higher and consumer staples and industrials the only two lagging sectors. Earlier, the index briefly gained to above its intraday record of 2,119.59, after earlier topping its record close of 2,117.39 set in March.
The Dow Jones industrial average closed up 20.42 points, or 0.11 percent, or 18,058.69, with IBM leading advancers and 3M the greatest laggard. The blue chip index came within 1 percent of its record close in intraday trade before paring gains.
The Nasdaq closed up 20.89 points, or 0.41 percent, at 5,056.06.
Apple closed up nearly 1 percent to lead the Nasdaq higher ahead of the release of the Apple Watch on Friday. The iPhone maker also posts quarterly results on Monday after the bell.
The Nasdaq iShares biotechnology ETF (IBB) gained more than 1 percent in another boost to the Nasdaq.
Leading the blue chips, IBM closed up 2.95 percent after spiking more than 3.5 percent on positive follow-through from its earnings report on Monday. Overall revenue fell 12 percent in a continuing downward trend, but sales in the cloud and analytics segments rose 60 and 12 percent year over year, respectively.
Investors are "looking at it as a company that's turning around and showing some progress as it's turning around," said Paul Nolte, portfolio manager at Kingsview Asset Management.
In the S&P 500, AT&T jumped more than 4 percent after after the close Wednesday that beat estimates on revenue that came in slightly below expectations. The telecommunications firm said subscribers switched to other networks at a lower rate. The company also launched a $17.5 billion six-tranche bond to finance its acquisition of DirecTV.
Corporate news and the highest settlement in crude for 2015 sent telecommunications and energy higher to trade among the advancers in the S&P 500.
Earlier, stocks traded mildly lower, following a negative lead from index futures.
"I think the market, in the absence of anything, is trading off technicals," said Mark Luschini, chief investment strategist at Janney Montgomery Scott. "The market I think is looking at the various technical levels and is looking at whether it is going to break up or break down. It seems to want to go higher but every time it reaches the 2,108 level it breaks down."
Katie Stockton, chief technical strategist at BTIG, said in a note that "we expect upside follow-through in the days ahead to allow the SPX to break out from its triangle formation to a new all-time high. So far, earnings season is driving more breakouts on the charts than breakdowns, so we think it is only a matter of time before this is reflected by the major indices."
On Wednesday, the Nasdaq closed up within 15 points of its all-time closing high of 5,048.62. The S&P 500 closed within 10 points of its closing high of 2,117.39.
"I think we're in a period of consolidation," said Terry Sandven, chief equity strategist at U.S. Bank Wealth Management. "Equities have been grinding higher. Companies are looking for clarity into whether or not earnings have been set too low."
Among the slew of industrial earnings reports before the bell, Caterpillar surprised analysts by beating expectations on both earnings per share and revenue. The stock spiked 1.5 percent in morning trade.
CEO Doug Oberhelman said on CNBC's "Squawk Box" that the United States was a bright spot in terms of construction growth. However, he said investors should not expect a repeat of this quarter. The firm raised its earnings forecast while maintaining its revenue outlook.
"I don't extrapolate anything out of Caterpillar," said Peter Boockvar, chief market analyst at The Lindsey Group, noting negative reports from other industrials. "Not one of them is going to drive the market. ... It's very much a mixed bag. The market is looking for direction and we may have to wait until next week's Fed meeting."
The Federal Reserve meets next Tuesday and Wednesday but will not hold a press conference.
Dunkin' Brands jumped more than 8.5 percent after the firm reported better-than-expected first-quarter revenue and profit.
3M fell more than 3 percent after reporting earnings that missed expectations on both the top and bottom line. The company cited the impact of the strong dollar and cut its profit forecast for the year.
Read MoreEarly movers: PBR, MMM, CAT & more
General Motors closed down 3.3 percent after the firm delivered quarterly profit and revenue that missed expectations. Weaker volume in Brazil and Russia hurt sales, as well as the impact of weakening currencies in South America due to the strong U.S. dollar.
PepsiCo closed down about 1.6 percent after reporting a revenue decline of 3.2 percent to $12.22 billion in the first quarter ended March 21, from $12.62 billion a year earlier, largely due to a strong dollar. However, quarterly earnings topped analysts' expectations.
"Eventually, missing revenues and the increased warnings outlook from major companies, I think it eventually will affect stocks," said Peter Cardillo, chief market economist at Rockwell Global Capital. He expects stocks to eventually move lower.
The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, traded near 12.
About two stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 797 million and a composite volume of 3.6 billion in the close.
Crude oil futures settled up $1.58, or 2.81 percent, at $57.74 a barrel on the New York Mercantile Exchange. Gold futures ended up $7.40 at $1,194.30 an ounce.
The U.S. 10-year Treasury yield fell to trade near 1.94 percent. The U.S. dollar fell more than half a percent, with the euro near $1.08.
came in weaker than expected, at 481,000 in March, versus the 510,000 unitestimate.
The 11.4 percent decline follows a 7.8 percent month-on-month jump in February that brought sales to a near-seven-year high of 539,000, according to Robert Kuenzel at Daiwa Capital Markets.
Weekly jobless claims showed an increase of 1,000 to 295,000.
Manufacturing PMI showed that growth in the U.S. manufacturing sector dipped more than expected in April, with factory activity showing the slowest momentum since January, according to financial data firm Markit.
The preliminary U.S.Manufacturing Purchasing Managers' Index fell to 54.2 in April from the final March read of 55.7. Economists polled by Reuters had forecast the April figure would come in at 55.5.
Manufacturing data overseas was also weak. HSBC's preliminary reading of China's factory activity for April came in at 49.2, compared with a Reuters forecast for a 49.6 print.
Markit's German flash composite PMI, which tracks manufacturing and services activity, fell to 54.2 in April from an eight-month peak of 55.4 in March.
The negative data weighed on European equities but sent Asian stocks in Tokyo and Seoul to multi-year highs. Despite the PMI figures that indicated contraction in China, the Shanghai Composite ended mildly higher, up 0.4 percent, while the Hang Seng closed down 0.4 percent.
Greek Prime Minister Alexis Tsipras called for a speeding up of work to conclude a reform-for-cash deal with euro zone creditors to keep his country afloat after talks with German Chancellor Angela Merkel on Thursday. Both sides called the discussions constructive.
The leftist Greek premier met the conservative German leader before an emergency European Union summit on migration, a day before euro zone finance ministers meet in Riga to review the negotiations between Greece and its international lenders.
Disclosure: Comcast is the owner of NBCUniversal, the parent company of CNBC and CNBC.com.
—Reuters and CNBC's Jacob Pramuk and Fred Imbert contributed to this report.
On tap this week:
Earnings: Amazon.com, Google, Microsoft, Starbucks, Altera, Capital One, E-Trade, Juniper Networks, Newmont Mining, Pandora
Earnings: Biogen, AstraZeneca, American Airlines Group, Cabot Oil and Gas, State Street, Xerox, A.O. Smith, Tyco
8:30 am: Durable goods
More From CNBC.com: