NEW YORK - Sudden twists in the price of oil and currency trading turned the stock market into a roller-coaster ride Tuesday.

Major indexes opened lower as falling oil prices and a plunge in the Russian ruble weighed on markets. Less than an hour later, crude oil recovered and oil and gas producers surged, driving the Dow Jones industrial average up as much as 246 points in the morning.

By the end of the day, however, all of the gains were wiped out.

The Standard & Poor's 500 index ended with a loss of 16.89 points, or 0.85 percent, to 1,972.74.

The Dow Jones industrial average lost 111.97 points, or 0.65 percent, to 17,068.87, while the Nasdaq composite dropped 57.32 points, or 1.24 percent, to 4,547.83.

The turbulence drove traders into the safety of U.S. government bonds, driving prices up and yields down. The yield on the 10-year Treasury note sank to 2.06 percent from 2.12 percent late Monday, a big move in the normally placid market.

Russia's currency, under pressure from lower oil prices and Western sanctions over Moscow's conflict with Ukraine, dropped 20 percent before recovering slightly. That followed a move by Russia's central bank to hike its benchmark interest rate to support the ruble.

The price of U.S. oil settled higher on Tuesday for the first time in a week, rising two cents to close at $55.93 a barrel in New York. Oil has fallen by nearly half since June as demand wanes and supply surges.

In other trading Tuesday, Talisman Energy soared 48 percent following news that Repsol, a Spanish oil and gas producer, plans to buy the Canadian company for $8.3 billion. The merger would create one of the world's largest privately owned oil and gas companies, Repsol said. Canadian courts and shareholders still have to sign off on the deal. Talisman's stock gained $2.46 to $7.58.

Apple fell $1.48, or 1.4 percent, to $106.75. The company said it has halted online sales of its iPhones, iPads, and other products in Russia, citing the financial turmoil triggered by the steep decline in the country's currency.

In metals trading, gold declined $13.40 to $1,194.30 an ounce, and silver fell 81 cents to $15.75 an ounce. Copper slipped two cents to $2.86 a pound.

Brent crude, a benchmark for international oils used by many U.S. refineries, fell $1.20 to close at $59.86 in London.

In other energy trading on the New York Mercantile Exchange, wholesale gasoline dropped 3.5 cents to close at $1.54 a gallon. Heating oil lost 4.2 cents to $1.96 a gallon. Natural gas dropped 10 cents to $3.62 per 1,000 cubic feet.