After a mostly flat trading day, the Dow and S&P 500 climbed during the last hours of trading Friday to finish the week at their highest levels since December 2007.

The Dow Jones industrial average rose 0.4% while the S&P 500 rose 0.3%. The Nasdaq finished the day in the red.

All three major indexes logged a third straight week of gains. The Dow gained 1.2%, the S&P 500 rose 1% and the Nasdaq added 0.3%.

Markets will be closed Monday in observance of Martin Luther King, Jr. Day.

Stocks spent most of Friday near the breakeven line as investors analyzed several corporate earnings reports.

A 6.3% drop in shares of Intel (INTC) weighed on all three indexes, particularly the tech-heavy Nasdaq, after the chipmaker reported that quarterly profits fell 27% from a year earlier.

Capital One (COF) was among the biggest losers on the S&P 500. Its shares fell more than 7% as the credit card lender and bank reported earnings that fell short of forecasts.

On the flip side, General Electric (GE) rose 3.5% after the conglomerate issued an upbeat outlook and reported better-than-expected earnings and revenue. GE was the biggest gainer on the Dow.

Morgan Stanley (MS)was also a big winner, with shares rising almost 8% after the bank reported earnings that narrowly beat expectations.

Related: Top 10 perks from Best Companies

It's been a mixed bag for earnings this week. JPMorgan Chase (JPM) and Goldman Sachs (GS) issued strong reports, while investors were disappointed by Citigroup (C)and Bank of America (BAC).

Overall, S&P 500 companies are expected to report earnings growth of 3.8% for the last three months of 2012, according to S&P's Capital IQ.

Related: Fear & Greed index mired in extreme greed

Investors also monitored the ongoing troubles at Boeing (BA), which has been in focus this week due to problems with its new 787 Dreamliners that prompted authorities around the world to ground the planes.

In international news, China's economy grew at a stronger-than-expected annual rate of 7.9% in the final three months of 2012. Asian stocks rallied on the news. The Nikkei surged nearly 3%, helped by a weaker yen.

European markets finished mixed. The FTSE 100 gained ground, while Germany's DAX and France's CAC 40 finished lower.

Back in the U.S., the University of Michigan's consumer sentiment index fell to 71.3 in January from 72.9 the previous month. Analysts were expecting a reading of 75.

The dollar gained versus the euro, the British pound and the Japanese yen.

Oil prices rose slightly, while gold prices slipped.

The price on the 10-year Treasury rose, pushing the yield down to 1.84% from 1.88% late Thursday.