Banks and smaller companies propelled stocks to their best January in 30 years, a sign that investors are favoring sectors tied to the U.S. economy.

Those groups were among the biggest laggards during the fourth quarter’s steep slide. Their reversal suggests that investors who were bracing for a sharp slowdown in U.S. economic activity have been soothed by cautious comments from the Federal Reserve, signs of strength in the labor market and data pointing to tepid inflation.

The...