Stocks gained after a week of heightened volatility on Friday, but investors were reluctant to make big bets due to turmoil in the Middle East and Japan's nuclear crisis.

The S&P and Dow ended lower for the second straight week as volatility spiked. The two-day rally that ended the week wasn't enough to offset losses early in the week that briefly erased the indexes' 2011 gains.

About 9.61 billion shares traded in composite action on Friday, more than average but still lower than recent selloffs. Quadruple witching, the quarterly expiration and settlement of March equity options and futures, contributed to Friday's volume.

Markets are bracing for more volatility, judging by the elevated levels in the Chicago Board Options Exchange Volatility Index <.VIX>, which fell 6.4 percent on Friday but is up 23 percent on the week. VIX futures contracts traded at a discount to the spot VIX, however, which suggests expectations for wild swings only for a short period.

The reason we're up the past couple of days is that the market has been coming to grips with the fact that from an economic perspective, the issue in Japan won't derail the recovery, said Russ Koesterich, investment strategist at BlackRock Inc, which oversees $3.56 trillion. Koesterich said he expected the VIX to maintain its recent advance.

Bank shares jumped as the Federal Reserve announced it will allow some U.S. banks to boost or restart dividend payments. Wells Fargo and Co and JPMorgan Chase immediately announced dividend increases. Wells Fargo rose 1.5 percent to $31.83 while Dow component JPMorgan jumped 2.6 percent to $45.74.

This is certainly very positive as the recovery will need to be led by banks, but I think this will be trumped in the days ahead by the technical repair work the market needs to do, said Kenneth Polcari, managing director at Icap Corporates in New York.

The Bank of Japan bought billions of dollars to restrain a soaring yen and was followed by U.S. and European central bank purchases. The iShares MSCI Japan Index Fund was up 3.1 percent.

The Dow Jones industrial average <.DJI> was up 83.93 points, or 0.71 percent, at 11,858.52. The Standard & Poor's 500 Index <.SPX> was up 5.49 points, or 0.43 percent, at 1,279.21. The Nasdaq Composite Index <.IXIC> was up 7.62 points, or 0.29 percent, at 2,643.67

The Dow fell 1.5 percent in the week while the S&P was off 1.9 percent and the Nasdaq, in its fourth straight down week, sank 2.6 percent.

Brent crude was down 0.9 percent to $112.30 a barrel in volatile trading after Libya announced a ceasefire and agreed to halt military action against rebels after a U.N. resolution.

The yen fell broadly, with the dollar gaining as much as two yen against the Japanese currency. On Thursday the yen rose sharply in the aftermath of the earthquake and tsunami, which threatened to aggravate the country's economic woes by stalling exports.

The CurrencyShares Japanese Yen Trust traded on many times its average daily volume, with most of the action in the March $124 and $125 put options ahead of the contracts expiration after the close, a sign that some investors taking profits following Thursday's sharp rally, said WhatsTrading.com options strategist Frederic Ruffy.

Almost three stocks rose for every one that fell on the New York Stock Exchange while more than two-thirds of the Nasdaq was in positive territory.

(Additional reporting by Doris Frankel; Editing by Kenneth Barry)