By Anna Hirtenstein and Frances Yoon

U.S. stocks rose Tuesday as millions of Americans headed to the polls, setting markets up for a second consecutive session of strong gains.

The Dow Jones Industrial Average rose 540 points, or 2%, while the S&P 500 gained 1.7% and the tech-heavy Nasdaq Composite added 1.7%. After losing 5.6% last week, the S&P 500 gained 1.2% Monday.

Historically, stocks have fared well on Election Day. Ahead of Tuesday, the S&P 500 rose 0.8% on average on the nine days from 1984 to 2016 that Americans went to the polls to elect a president. The index climbed on seven of those occasions.

Equities have also generally performed well under President Trump -- the S&P 500 has surged 55% since the 2016 election. But the market lately is being buoyed partly by bets that former Vice President Joe Biden will win the White House and Democrats will take control of Congress.

The stock market usually feels more apprehensive about Democrats than Republicans, but "this is a unique year and a unique election," said Solita Marcelli, the Americas chief investment officer at UBS Global Wealth Management.

Elections and stocks do have a relationship, though it is impossible to say definitively which drives the other. For election years since 1928 in which the S&P 500 is positive in the three months before election day, the incumbent party has won 87% of the time, according to brokerage firm BTIG.

Including this morning's gains, the S&P 500 is up more than 2% since Aug. 3.

The market has warmed to the chances of a "blue wave" outcome, in which Democrats win both the White House and control of Congress, Ms. Marcelli said, because it would make it more likely lawmakers approve a generous stimulus package to spur economic activity under the new administration.

"A lot of people were very fearful of a blue wave and Biden, pricing in what it would mean for taxes and regulations," she said. Those fears have receded though. "The market has come around quite a bit."

If Democrats emerge as the winners, the government could spend an additional $3 trillion to bolster the U.S. economy, said Stephane Monier, chief investment officer at Lombard Odier. That would give fresh impetus to a stock-market rally that has waned in recent weeks.

"We'll wait to have the first part of the results, and add risk to our client portfolios in the case of a clear Democratic or Republican sweep, " said Mr. Monier. "We will stay very cautious in the case of a split result."

If the Democrats emerge victorious, he said he plans to buy emerging-market equities. If it is a Republican win, Mr. Monier plans to invest in small and midcap stocks.

The yield on the benchmark 10-year U.S. Treasury bond rose to 0.877%, hovering close to the highest level since June, from 0.848% Monday. Prices fall when yields rise.

A Biden win could mean "more fiscal stimulus, where we could get stronger growth outcomes and higher inflation," said Seamus Mac Gorain, head of global rates at J.P. Morgan Asset Management. This would weigh on the government debt market, which tends to underperform in times of higher economic growth. "If we see a Democratic sweep, [10-year Treasury] yields could go up to 1% or potentially higher," he said.

The WSJ Dollar Index, which measures the greenback against a basket of currencies, declined 0.5% to the lowest level in a week. The biggest reaction to the elections might be in currency markets, rather than in stocks, said Eoin Murray, head of investments at Federated Hermes.

"An outright Biden win and the assumption around stimulus: You might see the dollar drop," said Mr. Murray. If Mr. Trump wins a second term, "there's a likelihood of more trade tensions and protectionism: you could see the dollar strengthen."

Despite the focus on the election, the long-term implications are less significant than most think, said Jason Pride, the chief investment officer of private wealth at Glenmede.

The firm broke down market performance by presidential administrations going back to 1872 and discovered that the market's long-term performance regardless of who held the White House and Congress was no more than 1% to 2% different than the overall average.

"I think the analysis on Republicans or Democrats being better for the market is a bunch of malarkey," he said. What ultimately matters is how corporations respond to government policies, and "corporations are surprisingly adept at finding ways to be profitable" no matter the environment, he said.

Among corporate issues, shares of Alibaba Group Holding slumped 7.4% after the Shanghai Stock Exchange postponed technology startup Ant Group's blockbuster initial public offering. Alibaba owns a 33% stake in Ant.

Cloud-computing firm Arista Networks surged 15% after it raised its outlook for fourth-quarter revenue. PayPal shares dropped 4.3% after it released expectations for next-quarter earnings that were below estimates.

In commodities, U.S. crude oil futures gained 2.3% to $37.66, following broader markets higher.

Overseas, the pan-continental Stoxx Europe 600 added 2.3% on optimism about global economic growth prospects. In Asia, most major benchmarks advanced. The Shanghai Composite Index rose 1.4%, and Hong Kong's Hang Seng climbed 2%. Japanese markets are closed for a holiday.

Write to Anna Hirtenstein at anna.hirtenstein@wsj.com and Frances Yoon at frances.yoon@wsj.com

(END) Dow Jones Newswires

11-03-20 1550ET