US stocks rose on Monday as crude oil jumped to its highest price in more than a year and energy companies climbed with it.
Oil rose after Russia's government said it supports efforts by Opec to cut oil production, while investors also reacted to the latest twists in the US presidential race.
Apple reached its highest price of the year and led tech stocks higher after new reports of fires affecting Samsung's Galaxy Note 7 phone, which competes with Apple's iPhone. Early in the day stocks were on track for far larger gains.
Steve Chiavarone, an associated portfolio manager for Federated Investors, said a tumultuous weekend for Republican candidate Donald Trump contributed to the market's gains.
He said investors mostly expect Democratic candidate Hillary Clinton to win, and they are concerned about the effect Mr Trump's trade proposals would have on the market and the economy.
"What you're seeing in the market is a cheering of the status quo," he said.
In his view, that is because investors understand Mrs Clinton's views and what her administration might look like even though they may disagree with her on issues such as tax policy.
The Dow Jones industrial average picked up 88.55 points, or 0.4%, to 18,329.04. The index rose as much as 159 points earlier. The Standard & Poor's 500 index rose 9.92 points, or 0.5%, to 2,163.66. The Nasdaq composite added 36.27 points, or 0.7%, to 5,328.67.
Russian president Vladimir Putin said that Russia supports Opec's efforts to cut oil production.
In late September the nations of Opec announced a preliminary agreement to trim oil production, but Russia, a major energy producer, is not a member of Opec.
Benchmark US crude rose 1.54 dollars, or 3.1%, to 51.35 dollars a barrel in New York. That was its highest closing price since July 2015. Brent crude, used to price international oils, gained 1.21 dollars, or 2.3%, to 53.14 dollars a barrel in London.
Exxon Mobil climbed 1.70 dollars, or 2%, to 88.44 dollars and Devon Energy added 1.58 dollars, or 33.7%, to 44.39 dollars.
Apple climbed 1.99 dollars, or 1.7%, to 116.05 dollars as investors hope it will be able to sell more iPhones as competitor Samsung faced new problems with its Galaxy Note 7.
Samsung said it has changed its production of the phones following reports that some of its replacement phones are overheating and catching fire, just as the original version of the phone did before Samsung recalled it last month.
Samsung did not confirm or deny a report from a Korean news agency that it suspended production of the Note 7 phone.
Drugmaker Mylan gained 2.93 dollars, or 8.2%, to 38.87 dollars. On Friday the company agreed to pay 465 million dollars to settle allegations it overcharged the Medicaid programme for its EpiPen allergy shot. Legislators and federal health authorities had said Mylan wrongly classified EpiPen as a generic drug instead of a brand-name one, which meant Mylan paid lower rebates to federal and state Medicaid programmes. The stock is down 20% since late August.
Bristol-Myers Squibb plunged again after the company reported more data from a study of its drug Opdivo in lung cancer patients. It fell 5.62 dollars, or 10.1%, to 49.81 dollars. Rival Merck rose 1.13 dollars, or 1.8%, to 63.90 dollars as investors were pleased with results from a study of its cancer treatment Keytruda. Bristol-Myers stock has dropped 34% since the company announced initial results from that trial in early August, which has sent it to almost two-year lows. Merck is up 10% over the same time.
The Mexican peso grew stronger following Mr Trump's calamitous weekend.
Mr Trump has criticised Mexico and its trade agreements with the US, so the peso has become something of an indicator of how investors feel about the election.
The currency has tended to weaken when investors feel Mr Trump is doing better and gets stronger when investors feel more confident in Mrs Clinton's chances. The US buys about 80% of Mexico's exports, which gives it a big influence on the Mexican economy.
Following the peso's surge on Monday, one US dollar bought just 18.92 pesos, versus the 19.26 pesos it bought on Friday. The peso has weakened sharply this year but is currently the strongest it has been in about a month.
Twitter continued to fall as investors grew less optimistic that the company will be sold.
Twitter sank 2.29 dollars, or 11.5%, to 17.56 dollars. It fell 20% on Thursday on reports that possible buyers including Apple and Alphabet had decided not to make offers.
Twitter has been on a big run since late July on rumours the company might be sold.
The stock is now the lowest it has been since early August.
Salesforce.com, which investors believe is a possible buyer, rose 4.19 dollars, or 5.9%, to 75.10 dollars.
Manufacturer Dover forecast a smaller profit and a bigger decline in revenue because of weaker spending in several industries and production problems in its retail refrigeration unit. The company also said its purchase of British company Wayne Fueling Systems will not close until early next year because regulators in the United Kingdom are still reviewing the deal. The stock gave up 5.55 dollars , or 7.7%, to 66.69 dollars .
Gold rose 8.50 dollars to 1,260.40 dollars an ounce. Silver added 28 cents to 17.66 dollars an ounce. Copper picked up three cents to 2.20 dollars a pound.
Germany's DAX rose 1.3% and the CAC-40 in France was 1.1% higher. The FTSE 100 in London rose 0.8%. The Kospi in South Korea rose 0.1%. Japan's markets were closed for a holiday.
The dollar rose to 103.68 yen from 103.06 yen on Friday. The euro fell to 1.1139 dollars from 1.1182 dollars, and the British pound fell to 1.2351 dollars from 1.2435 dollars. Bond trading was closed for the Columbus Day holiday.