Polls indicated President Barack Obama and Republican challenger Mitt Romney remained in a neck-and-neck race, although the Democratic incumbent has a slight edge in several key swing states.
The general view on Wall Street is that a Romney win would favor stocks due to the perception his policies are pro-business, while another Obama term would favor bonds due to views his policies would keep interest rates low.
Analysts downplayed the stock market's advance as traders' betting on Romney pulling out a victory.
"There's been a lot of talk that once the election is decided, no matter how it went, just to have the uncertainty over would be good for the market," said Rick Meckler, president of hedge fund LibertyView Capital Management LLC in Jersey City, New Jersey.
Traders seemed more concerned over how the election results will affect the US government's handling of the "fiscal cliff," the $600 billion worth of automatic tax hikes and spending cuts set to kick in on January 1 unless Congress takes action.
Economists have said the spending cuts and tax hikes could ignite a new recession in the world's biggest economy, while Europe continued to struggle with a prolonged debt crisis that has hurt regional growth.
There is no clear consensus in financial markets on whether Obama or Romney could reach a timely deal with leaders of the opposing party to avoid the fiscal cliff.
"We do know this much," said Peter Kenny, managing director at Knight Capital in Jersey City, New Jersey. "Though the resident in the White House may change, the face of Washington is still going to be one of tremendous gridlock, discord and dysfunction, and markets are going to force Washington to come to terms with the dysfunction."
The winner will also decide who will head the Federal Reserve. There has been speculation Chairman Ben Bernanke, whose term expires in January 2014, might not want to serve another term. Romney has said he will not reappoint Bernanke.
"If Obama wins, we would be certain Ben Bernanke would remain in office as Federal Reserve chairman at least until his normal term expires," said Peter Fertig, a consultant with Quantitative Commodity Research in London.
On below-average volume, the Dow Jones industrial average was up 125.17 points, or 0.95 percent, at 13,237.61 shortly before the closing bell. The Standard & Poor's 500 Index was up 9.98 points, or 0.70 percent, at 1,427.24. The Nasdaq Composite Index was up 9.02 points, or 0.30 percent, at 3,008.68.
Express Scripts Holding Co plunged 12.5 percent to $55.03 and was the biggest drag on the Nasdaq after the pharmacy benefits manager said analysts' forecasts for its 2013 results were too aggressive, casting doubt on how well it is integrating its $29 billion purchase of Medco Health Solutions Inc.
Emerson Electric Co climbed 2.2 percent to $51.60 after the industrial conglomerate posted adjusted earnings that topped Wall Street expectations and said it will pursue a sale of its $1.4 billion embedded computing and power business.
Top European shares closed 0.56 percent higher, rebounding from Monday's losses, boosted by strength in the technology and travel and leisure sectors.
Hannover Re, the world's third-biggest reinsurer, ended up 4.5 percent at 55.90 euros after its quarterly profit beat forecasts and it lifted its expectations for 2012 and 2013.
World stocks on the MSCI global index were up 0.59 percent after back-to-back losing sessions.
Developments in Greece were also being keenly followed. The Greek parliament will vote o n Wednesday on 13.5 billion euros of fresh spending cuts and tax hikes that are crucial to unlocking 31.5 billion euros in aid. There will be a follow-up vote on Sunday on an austerity budget for 2013.
"Suffice to say if the vote fails, the euro will drop and the dollar will rally, but even if the vote passes, any rally in the euro will be short-lived," said Neil Mellor, currency strategist at Bank of New York Mellon in London.
The euro recovered against the dollar at $1.2811, little changed on the day, after the single currency fell to a two-month low at $1.2764.
The dollar retreated from a two-month high against a basket of major currencies. The dollar index last traded down 0.14 percent at 80.634.
In the bond market, U.S. Treasuries prices and German government debt fell, reversing Monday's safe-haven gains tied to uncertainty about the U.S. election.
Benchmark 10-year Treasury notes were down 19/32 in price to yield 1.745 percent, up 7 basis points from Monday. German Bund futures were 36 basis points at 141.77.
In commodity markets, Brent crude oil settled up $3.34 at $111.07 a barrel and U.S. oil futures jumped $3.06 at $88.71, tracking gains in equities markets.
Gold was poised for its biggest one-day gain since mid-September, rebounding from a nine-week low set on Monday. Bullion was up 1.9 percent at $1,715.35 an ounce.