U.S. stock markets smashed records Thursday as investors tuned out politics and trade to focus on a flourishing economy that is producing robust corporate earnings.

The S&P 500 and Dow Jones industrial average closed at record highs on Thursday, finishing up 0.8 percent and 1.0 percent respectively. The S&P closed up 22.80 points at 2,930.75. The Dow finished up 251 points, closing at 26,656.98. The tech-heavy Nasdaq composite index closed at 8,028.23, up 1.0 percent.

It’s the S&P’s 19th record close this year and its 89th since the 2016 elections. The Dow recorded its 12th closing high of the year and its 100th new high since the presidential election.

“The Dow has hit over 200 all-time highs since the market bottomed, which means that investors have had 200 reasons to sell at a high, and every one of those reasons have been wrong,” said Daniel P. Wiener, chairman of Adviser Investments, a Newton, Mass.-based firm.

President Trump, who has made the stock market gains one of the cornerstones of his presidency, jumped on the bandwagon Thursday morning, saying in a tweet, “S&P 500 HITS ALL-TIME HIGH Congratulations USA!”

Investors have been reacting to corporate stock buybacks, strong U.S. economic growth and predictions of another strapping quarter of profits, analysts say.

Scott Wren, senior global equity strategist for Wells Fargo Investment Institute, said that ­second-quarter earnings were up 25 percent over the year before and that more than 80 percent of companies beat Wall Street expectations.

A big chunk of the profits and stock gains are coming on the tail of the corporate tax cuts passed by the Republican-controlled Congress last December. The first three months of the year showed a dramatic rise in corporate buybacks, compared with the previous quarter, according to a recent report by three Federal Reserve economists. Buybacks tend to raise a company’s stock price by reducing the number of shares on the market.

“It feels like the market is going nuts, but the equity markets are behaving like equity markets,” said Binky Chadha, head of asset allocation at Deutsche Bank.

Thursday’s gains were broad and deep.

There were only two spoilers out of the 30 Dow components. Oil major Chevron and home improvement retailer Home Depot saw their shares drop.

“There’s been a shift in attitude . . . a move to safety,” Wiener said. “Investors have shifted their focus to more industrial stocks. It’s battleship, balance-sheeet companies with strong dividend yield and strong dividend growth. You’re looking at Intel, Visa, IBM, Caterpillar and Disney.”

On Thursday, the sturdy U.S. economy got another blue-sky report with a Labor Department jobs claim announcement that showed that layoffs are at their lowest rate in 49 years.