The S&P 500 rose 8.54 points to 1,517.93, closing 0.3 percent up for the week. The index is at its highest since November 2007 and has advanced for six weeks, the longest streak of gains since August.
The Dow Jones industrial average rose 48.92 points, or 0.4 percent, to 13,992.97. The Nasdaq composite climbed 28.74 points, or 0.9 percent, to finish the week at 3,193.87.
The Dow had its best January in almost two decades, and closed above 14,000 on Feb. 1 for the first time since 2007. The index is up 6.8 percent so far this year; the S&P 500 is up 6.4 percent.
A last-minute budget deal in Washington to avoid the "fiscal cliff" of tax hikes and spending cuts helped powered the rally, as did as optimism about the housing sector and gradual improvements in the jobs market.
The S&P 500 finished the week higher despite logging its biggest daily decline in almost three months Monday following worrying news from Europe.
The index fell 1.2 percent that day as bond yields in Spain and Italy rose on concern that the region's politicians will drag Europe back into crisis. European Central Bank President Mario Draghi's cautious comments about the region's economy also weighed on markets Thursday.
"Everybody seems to be saying this market needs to correct," said Robert Pavlik, chief market strategist at Banyan Partners. "Nobody wants to be in it, but nobody wants to be out of it."
Largely positive corporate earnings reports and a report that showed that the U.S. trade deficit narrowed sharply in December provided more fuel for the market's advance Friday.
The trade deficit fell nearly 21 percent in December from November to $38.6 billion, the smallest in nearly three years, as exports rose while oil imports plummeted. The smaller trade gap means the economy likely performed better in the final three months of last year than first reported last week.
"The trade balance was surprisingly very good," said Phil Orlando, chief market strategist at Federated Investors.
The government estimated that the U.S. economy contracted at an annual rate of 0.1 percent in the last three months of 2012. Orlando estimates that may now be revised to growth of 0.5 percent.
Shares of LinkedIn, the online professional networking service, jumped $26.39, or 21.3 percent, to $150.40 after the company reported fourth-quarter results late Thursday that beat analysts' forecasts. AOL soared $2.31 to $33.72 after the Internet company said its quarterly revenue grew for the first time in eight years, helped by strength in worldwide advertising.
Currently, analysts are expecting earnings for the fourth quarter of 2012 to rise 6.5 percent for S&P 500 companies, according to data from S&P Capital I&Q. That's an increase from the 2.4 percent growth rate recorded for the preceding quarter.
Stocks have benefited as investors poured a net $4.1 billion into stock mutual funds since the start of the year, according to data provided by Lipper.
"I'm very encouraged by the fact, that finally, for the first time in many years, individual investors seem to be participating in this," said David Kelly, chief global strategist at J.P. Morgan Funds.
The yield on the 10-year note, which moves inversely to its price, fell one basis point to 1.95 percent.
Trading volume was light as Wall Street braced for what is forecast to be the largest winter storm in more than a year. Up to 2 feet of snow forecast along the densely populated Interstate 95 corridor from the New York City area to Boston and beyond.
Among other stocks making big moves;
-- Microchip Technology, a semiconductor maker, jumped $2.45, or 7.2 percent, to $36.39 after its earnings beat estimates. The company said it was seeing "exceptionally strong" bookings.
-- Moody's slumped $3.62, or 7.7 percent, to $43.37 even after reporting that fourth-quarter net income jumped 66 percent and revenue blew away expectations. Many are expecting the ratings agency will be the next target of the Justice Department, which filed a suit against rival Standard & Poor's for its actions before the housing market collapse.
-- Activision Blizzard, which makes "Call of Duty" and other video games, rose $1.35, or 11.2 percent, to $13.41. The company posted sharply higher earnings and revenue in the fourth quarter, surpassing Wall Street's expectations.
MORE HBJ HEADLINES
Volkswagen Golf gets great mpg, even in the left lane Google expanding fiber service to 4 Southeastern metro areas Fishermen fear monopoly by Pacific Seafood Group Unemployment rates fall in 42 US states amid broad hiring Safety board: Systemic flaws in gas pipelines oversight A US green-energy blueprint, meant to help Liberia, fails
Our new comment system is not supported in IE 7. Please upgrade your browser here.