The gains came after a 7.1-magnitude earthquake occurred around 10:30 a.m. ET, near the same location off the coast of Japan as the March 11 earthquake.

Japan's news agency NHK issued a tsunami warning for roughly the same area that had been deluged by water less than a month ago. The tsunami warning was lifted two hours later, with no reports of major damage.

NHK said the troubled Fukushima-Daiichi nuclear power plant did not experience any further damage from Thursday's earthquake.

But the second earthquake stoked fears about the long-term viability of nuclear power in Japan, and revived speculation about a short-term spike in energy demand as the nation rebuilds, said Doug Roberts, chief market strategist for Channel Capital Research.

"It also creates uncertainty in the market," he said. "And whenever there's uncertainty, people tend to build in a speculative premium."

The crisis at the Daiichi plant, where workers have been struggling to cool reactors and contain radioactive leaks, has heightened concerns about the safety of nuclear power in a country prone to violent seismic activity.

While Japan could use fossil fuels such as diesel to deal with temporary shortfalls in electricity, analysts said natural gas is a more likely substitute if the nation moves away from nuclear power over the long term.

Meanwhile, oil prices have surged some 20% so far this year as the political spasms in North Africa and the Middle East have raised worries about supply.

In Libya, oil production has been almost entirely halted for weeks amid a deadly stalemate between forces loyal to Moammar Gadhafi and rebel fighters.

Oil prices were also supported Thursday by signs that the European Central Bank is not about to embark on a long-term campaign to raise interest rates, said Tom Pawlicki, an energy analyst at MF Global.

In a press conference following the decision, ECB President Jean-Claude Trichet said the hike was necessary to "firmly anchor" rising prices, adding that interest rates are still low, "very accommodative" and able to spur further economic growth.

Looking ahead, Pawlicki expects the market to hold Thursday's gains, although he said Japan will probably not be the main driver going forward.

"I think the rally will be sustained but the reasons will probably change," he said. "The market will refocus on the Libya stalemate and expectations that low interest rates will be maintained."