NEW YORK >> U.S. stocks rallied Tuesday as voters headed to the polls on the last day of the presidential election and as more data piled up showing the economy remains solid.

The S&P 500 rose 1.2% to pull closer to its record set last month. The Dow Jones Industrial Average climbed 427 points, or 1%, while the Nasdaq composite gained 1.4%.

All told, the S&P 500 rose 70.07 points to 5,782.76. The Dow gained 427.28 to 42,221.88, and the Nasdaq composite rallied 259.19 to 18,439.17.

The market got a lift from a report showing growth accelerated last month for retailers, transportation companies and other businesses in the U.S. services industries. That was despite economists’ expectations for a slowdown, and the Institute for Supply Management said it was the strongest growth in more than two years.

The report offered more hope that the U.S. economy will remain solid and avoid a long-feared recession following the worst inflation in generations.

Excitement about the artificial-intelligence boom also helped lift the stock market, as it has for much of the last year. Software company Palantir Technologies jumped 23.5% after delivering bigger profit and revenue than analysts expected for the latest quarter. It’s an industry known for thinking and talking big, and CEO Alexander Karp said, “We absolutely eviscerated this quarter, driven by unrelenting AI demand that won’t slow down.”

It helped offset a 5.2% drop for NXP Semiconductors. The Dutch company fell to one of the largest losses in the S&P 500 after warning that weakness it saw in the industrial and other markets during the latest quarter is spreading to Europe and the Americas.

The market’s main event Tuesday was the election, even if the result may not be known for days or weeks as officials count all the votes. Such uncertainty could upset markets, along with an upcoming meeting by the Federal Reserve on interest rates later this week. The widespread expectation is for it to cut its main interest rate for a second straight time.

Many professional investors suggest keeping the focus on the long term. The broad U.S. stock market has historically tended to rise regardless of which party wins the White House, even if each party’s policies can help and hurt industries’ profits.

Since 1945, the S&P 500 has risen in 73% of the years where a Democrat was president and 70% of the years when a Republican was the nation’s chief executive, according to Sam Stovall, chief investment strategist at CFRA.

The U.S. stock market has risen more in magnitude when Democrats have been president, in part because a loss under George W. Bush’s term hurt the Republicans’ average. Bush took over as the dot-com bubble was deflating and exited office when the 2008 global financial crisis and Great Recession were devastating markets.

Other questions hanging over the market include whether the White House will be working with a unified Congress or one split by political parties, as well as whether the results will be contested.

The general hope among investors is often for split control of the U.S. government because that’s more likely to keep the status quo and avoid big changes that could drive the nation’s debt much higher.

As for a contested election, Wall Street has some precedent to look back to. In 2000, the S&P 500 dropped 5% in about five weeks after Election Day before Al Gore conceded to George W. Bush. That, though, also happened during the near-halving of the S&P 500 from March 2000 to October 2002 as the dot-com bubble deflated.