After one of the most volatile weeks in memory, U.S. stocks ended higher on Friday in a tentative sign that the worst of the selling may be over.

Volume was much lighter than on any other day of the week and intraday swings were far less violent than in previous days. Both signs suggested a drop in investor anxiety.

Still, the market was down for the week and posted its worst three-week decline since March 2009 when it hit 12-year lows.

About 9 billion shares traded on the New York Stock Exchange, NYSE Amex and Nasdaq, sharply lower than the daily average of nearly 16 billion shares traded earlier this week. It was the busiest week in terms of volume since October 2008.

Today's slowdown in volume is clearly indicative of people getting a little bit more comfortable about where the market is, said Ken Polcari, managing director at ICAP Equities in New York.

Blue-chips garnered more attention from investors looking for relative safety in the equity market. Boeing gained 4.9 percent to $61.75, leading the Dow industrials.

The hope among investors is stocks are in the process of exhausting the selling and will stabilize at current levels and eventually resume an upward trend.

Before moving higher the market needs to do some repair work and needs to build a base, and that's what we're doing right now, Polcari said.

Analysts at Bank of America/Merrill Lynch said in a note the U.S. equities market is already fairly priced for a recession. This suggests any indication to even sluggish growth could boost stocks.

U.S. markets got support on Friday from a 3.6 percent rise in European shares. A short-selling ban on financial shares by France, Italy, Spain and Belgium eased fears over recent sharp declines.

U.S. retail sales posted the biggest gains in four months in July, which also boosted buying.

The Dow Jones industrial average gained 125.71 points, or 1.13 percent, to 11,269.02. The Standard & Poor's 500 Index added 6.17 points, or 0.53 percent, to 1,178.81. The Nasdaq Composite Index rose 15.30 points, or 0.61 percent, to 2,507.98.

It was the first two-day rally on the S&P 500 since July 21-22.

For the week, the Dow fell 1.5 percent and the Nasdaq lost 1 percent. The S&P 500 fell on 11 of the past 15 days, dropping 12.4 percent in three weeks.

The recent declines reflect softening U.S. and global economic data and a market perception that government leaders in Europe and the United States were running out of options to help their sputtering economies. The downgrade of the United States' credit rating by Standard & Poor's a week ago exacerbated those views.

A report on Friday showed U.S. consumer sentiment fell in early August to the lowest level in more than three decades.

Among individual stocks, Nvidia Corp shed 4 percent to $12.88, giving back sharp gains. Late Thursday, it forecast a larger-than-expected jump in revenue but some analysts were surprised with the lack of growth in one of its much-touted processors.

Retailer Dillard's Inc slumped 18.2 percent to $41.51 after it posted quarterly profits below estimates.

Advancers beat decliners on the New York Stock Exchange by about nine-to-five, while on the Nasdaq 1,320 issues advanced and 1,239 fell.

(Reporting by Rodrigo Campos; Editing by Kenneth Barry)