The prospect of falling oil demand from Japan sent crude oil prices down to $101 a barrel. Industrial and materials companies rose on expectations that they will benefit from Japan's rebuilding efforts.
One day after its biggest fall since August, the Dow Jones industrial average gained 59.79 points, or 0.5 percent, to 12,044.40. The S&P 500 rose 9.17, or 0.7 percent, to 1,304.28. The Nasdaq composite gained 14.59, or 0.5 percent, to 2,715.61.
In addition to the earthquake, oil prices fell after a scheduled day of protests in Saudi Arabia only drew a few hundred people, and the capital remained quiet. Oil traders have been worried the violence in the Middle East and North Africa would spread to the world's No. 1 oil exporter.
"The market is going to be see-sawing back and forth" until the long-term effects of the unrest in the Middle East and the disaster in Japan become clear, said Anthony Chan, chief economist for J.P. Morgan Wealth Management.
The earthquake and oil protests largely overshadowed a report from the Commerce Department that retail sales rose 1 percent in February, the biggest gain in four months and more than the 0.8 percent analysts had expected. Shoppers laid out more cash for cars, clothing and gadgets in February, leading to an eighth month of gains.
Despite Fridays' gains, each index finished the week lower. The Dow fell 1 percent, while the broader S&P index lost 1.3 percent.
Stocks fell sharply Thursday on weak economic news from China, the U.S. and Spain combined with a slump in oil company shares. The Dow Jones industrial average had its biggest drop since August 11. Other than several large swings in the past month, stocks have been climbing steadily since September.
"It could be time for a well-deserved rest," said Ryan Detrick, senior technical strategist for Schaeffer's Investment Research. "The markets had a spectacular six-month rally and now they're showing some slight cracks."
The quake caused a sell-off in global stock markets, led by sharp drops in insurance companies. Japan's Nikkei closed down 1.7 percent. The yen remained stable, however, because it is seen as a relatively safe investment for international traders.
The yield on the 10-year U.S. treasury note rose to 3.41 percent from 3.37 percent late Thursday.
Two stocks rose for every one that fell on the New York Stock Exchange. Consolidated volume came to 3.8 million shares.