Stocks endured an erratic session Tuesday but closed with robust gains, as investors focused on a surprise gain in jobs and government help for the financial and housing sectors instead of rising oil prices.