(CNBC) The Dow and S&P 500 turned decisively higher in the final minutes of trading to close at their best level since December 2007 and all three major averages turned in their third-straight weekly gain.

Stocks wavered around the flatline for most of the session following a weaker-than-expected consumer sentiment report and a mixed batch of corporate earnings.

Note: Read our discussion guidelines before commenting.