U.S. stocks notched meager gains Thursday, but the Nasdaq closed at a record after former FBI Director James Comey’s appearance in front of the U.S. Senate Intelligence Committee concluded without any significant revelations.

The Dow Jones Industrial Average DJIA, +1.33% rose 8.84 points to finish, less than 0.1%, at 21,182.53 after hitting an intraday record of 21,265.69 on strong gains in Caterpillar Inc. CAT, +0.53% and Goldman Sachs Group Inc. GS, -0.08% .

The S&P 500 index SPX, +1.59% added 0.65 point to close at 2,433.79. Financials rallied 1.1% while utilities were the biggest decliners.

The Nasdaq Composite Index COMP, +2.26% gained 24.38 points, or 0.4%, to end at 6,321.76 after setting an intraday record of 6,324.06.

“It is evident from the market’s reaction that the testimony is more hype than substance, equivalent to preparing for a major storm that may not occur,” said Kent Engelke, chief economic strategist at Capitol Securities Management Inc.

Comey’s testimony is part of a litany of potentially market-moving events playing out over the next 24 hours, including an earlier decision by the European Central Bank to keep its monetary policy unchanged and a U.K. snap election.

However, Wall Street investors have signaled that events don’t appear to threaten the stock market’s extended push into record territory, which has been driven by President Donald Trump’s promises of tax cuts, infrastructure spending and deregulation.

Comey’s statement, released Wednesday, suggested he was worried Trump had sought to secure his “loyalty” and wanted him to help “lift the cloud” from the investigation into possible Russian interference in the U.S. election was casting. Comey also confirmed the president’s assertion that the director had repeatedly assured Trump that the Federal Bureau of Investigation hadn’t opened an investigation into him. He reiterated those assertions during his testimony in front of the Senate panel.

Engelke, meanwhile, believes that the House passage of legislation to roll back the Dodd-Frank financial regulatory bill is likely to accelerate circulation of capital in the markets and boost economic activity.

Phil Orlando, chief equity strategist at Federated Investors, said absent any surprises, recent events suggests that the stock market should drift higher.

“Ultimately, stock markets are going to reflect earnings,” he said.

Orlando said the U.S. and Europe are showing strong quarterly results that may help to support gains in stocks that some strategists and investors view as overvalued.

Earlier in the day, the ECB, as expected, left interest rates unchanged but said it continued to expect interest rates “to remain at present levels for an extended period of time, and well past the horizon” of its asset-buying program, which is set to run at least through December. In previous statements, the ECB had said it expected rates “to remain at present or lower levels for an extended period of time.”

Check out: A recap of the ECB’s Mario Draghi news conference

Read:Why the ECB can take only ‘baby steps’ toward ending ultraloose monetary policy

Comey’s statement on Trump meetings reads like a screenplay

Beyond the ECB and Comey, investors also were focused on the U.K. general election,

In the U.K., voters headed to the polls in an election that turned out to be much more uncertain than predicted. Opinion polls are still giving Prime Minister Theresa May’s Conservative Party the lead, but the big question is whether the party will increase its majority in parliament. Polling stations close at 10 p.m. London time, or 5 p.m. Eastern, and the first exit polls will be released soon after.

Read:U.K. election—these are the stocks and sectors to watch once the result is in

Also read:U.K. election: The worst, best and most likely scenarios for stocks world-wide

The pound GBPUSD, +0.01% traded at a two-week high as voting got under way, buying $1.2946, compared with $1.2960 late Wednesday in New York.

Economic news: A reading on weekly jobless claims dropped by 10,000 to 245,000 in the seven days stretching from May 28 to June 3, nearest the lowest levels in decades.

Stock movers: Shares of Yahoo! Inc. US:YHOO rallied 10.2% after news late Wednesday that up to 1,000 layoffs are expected at the combined Yahoo and AOL companies set to be bought by Verizon Communications Inc. VZ, +0.33% .

Advanced Micro Devices Inc. AMD, +2.94% rose 4.2% as shares build on recent days’ sharp rally following upbeat comments from Apple Inc. AAPL, +3.75% and brokers regarding the chip maker.

Shares of Alibaba Group Holding Ltd. BABA, +0.50% jumped 13% after the Chinese e-commerce giant said revenues are expected to grow between 45% and 49% in 2018.

Shares of Nordstrom Inc. JWN, -1.65% soared 10.3% following reports that the retailer is exploring taking itself private.

Other markets: Stocks in Asia closed mostly higher, although Japan’s Nikkei 225 index NIK, +0.50% bucked the positive trend. The losses in Tokyo came after the yen jumped on reports the Bank of Japan is running simulations of exits from quantitative easing.

European stocks were mixed following the ECB meeting and ahead of the U.K. election result.

Oil prices US:CLN7 ended mostly flat after posting the biggest drop since March in Wednesday’s session. That slump followed a report of an unexpected climb in U.S. stockpiles.

Gold US:GCQ7 settled sharply lower, while the dollar DXY, +0.23% was up 0.2% against other major currencies, including the euro.

—Sara Sjolin contributed to this article.