Shares of Apple Inc (>> Apple Inc.), the largest U.S. company by market value, ended at an all-time peak, and Exxon Mobil (>> Exxon Mobil Corporation), the second biggest, hit a four-year high.

Equities are in a run-up that has pushed the S&P 500 to end higher for four consecutive months. The extended advance has come mainly from actions by Europe's and the United States' central banks to keep interest rates low and stimulate their struggling economies.

The Fed said Thursday that it would keep up its aggressive bond-buying until unemployment falls. Chairman Ben Bernanke said he wanted to see a convincing improvement in the economy that could deliver sustainable job creation.

Bernanke's comments are "going to create an artificial floor on the market, meaning that we could see higher prices over time," said Paul Nolte, managing director at Dearborn Partners in Chicago. "Any correction that we get will be no more than a few percentage points."

The Dow and the S&P 500 both closed at their highest levels since December 2007, while the Nasdaq ended at the highest since November 2000. The small-cap Russell 2000 <.RUT> index closed at the highest since April 2011.

The Dow Jones industrial average <.DJI> ended up 53.51 points, or 0.40 percent, to 13,593.37. The Standard & Poor's 500 Index <.SPX> closed up 5.78 points, or 0.40 percent, to 1,465.77. The Nasdaq Composite Index <.IXIC> gained 28.12 points, or 0.89 percent, to 3,183.95.

For the week, the Dow rose 2.2 percent, the S&P climbed 1.9 percent and the Nasdaq added 1.5 percent.

The S&P is now just 6 percent below its all-time closing high of 1,565.15 despite a relatively weak economy and economic risks around the world.

The Fed's balance sheet could expand by 11 to 12 percent by the end of the year, monetary accommodation that could "translate into a move up in the S&P 500 stock index to the 1,505 area," Brian Jacobsen, chief portfolio strategist at Wells Fargo Funds Management, LLC in Menomonee Falls, Wisconsin, said,

Energy and material stocks led the gains as the Fed's move boosted commodity prices. Miner Freeport-McMoran Copper & Gold Inc (>> Freeport-McMoRan Copper & Gold Inc.) rose 2.03 percent to $42.64 and aluminum company Alcoa Inc (>> Alcoa Inc.) advanced 2.18 percent to $9.84. The PHLX Gold/Silver Index <.XAU> climbed 2.86 percent to its highest since early March.

The S&P energy sector index <.GSPE> rose 1.3 percent and the S&P materials sector index <.GSPM> was up 1.2 percent.

U.S. economic data released on Friday helped justify the Fed's decision to launch a third round of bond purchases to try to lower borrowing costs and spur growth.

A jump in the cost of gasoline pushed consumer prices up in August at the fastest pace in more than three years and squeezed spending on other items, threatening to further slow the already sluggish economy. Other data showed production at factories, mines and utilities dropped by 1.2 percent, the biggest decline since March 2009.

S&P Dow Jones Indices said UnitedHealth Group Inc (>> UnitedHealth Group Inc.) will replace Kraft Foods Inc (>> Kraft Foods Inc) in the Dow Jones industrial average after the close of trading September 21. UnitedHealth shares rose 0.67 percent to $54.25 and Kraft slipped 0.5 percent to $39.93.

Home Depot (>> The Home Depot, Inc.), the world's largest home improvement chain, was up 2 percent to $59.46 after the company announced it will close all seven of its big box stores and cut 850 jobs in China.

Shares of Staples (>> Staples, Inc.) were up 2.09 percent to $12.21 after Fortune magazine reported that several private equity firms, including Bain Capital, are considering a buyout offer for the retailer.

Total volume was 8.45 billion shares, above last year's daily average of 7.84 billion.

On both the New York Stock Exchange and Nasdaq, about two stocks rose for every one that fell.

(Editing by Kenneth Barry)

By Wanfeng Zhou