Lennar had a good number. Homebuilders was obviously an area that has been very weak, and for those guys that had a good number, that helped, said Stephen Massocca, managing director at Wedbush Morgan in San Francisco.

Stocks have rallied in recent weeks in part on optimism about stronger corporate profits, with the S&P up nearly 8 percent since the start of December.

However, the benchmark S&P 500 had lost ground over the past three sessions, leading some analysts to question whether stocks had become expensive or if the pullback meant stocks would climb again as earnings news rolled in.

It's getting a little frothy. Any little stock that has a little wiggle to it, a bunch of guys are piling into it, Massocca said.

Alcoa projected a 12 percent rise in demand for aluminum this year, which some analysts questioned, but others noted profit-taking could be factor. Alcoa shares had risen 24 percent since the start of December.

A white Fiat van rammed into pedestrians outside enjoying a late afternoon stroll on Las Ramblas in Barcelona on Thursday killing at least 13 people and leaving hundreds injured. The Islamic State group claimed responsibility for the attack.