CHICAGO — Americans packed lunches and made more dinners at home this spring, leading to traffic declines across the restaurant industry. For McDonald’s, the trend led to disappointing second-quarter results after months of strong growth.

McDonald’s, based in suburban Chicago, said Tuesday its second-quarter earnings slipped 9 percent on costs related to refranchising and relocating the company’s longtime headquarters, as well as slower industry growth. The results were below what Wall Street expected, and the stock fell more than 4 percent.

“I think there’s just a broader level of uncertainty … and when (consumers) are uncertain, caution starts to prevail,” CEO Steve Easterbrook said on a conference call after the results were released. Easterbrook acknowledged that there has been a “fairly well-documented consumer slowdown” in recent months, but said that McDonald’s is taking steps to counteract it.

That includes the expansion of all-day breakfast nationwide this fall, on the anniversary of the popular promotion’s inception in 2015. The new menu will include McGriddles nationwide and both biscuits and English muffins, instead of one or the other based on geography. McDonald’s and observers expected the boost from all-day breakfast to slow after the first few quarters, so the world’s largest burger chain is hoping that the breakfast expansion will keep customers coming in the door and buying more. All-day breakfast has led customers to spend more at lunch and dinner as they add breakfast items to their usual orders.

McDonald’s said it was able to improve customer traffic and make up for a slowdown industrywide by stealing more customers from its closest competitors. Easterbrook said that in light of the industry slowdown, “it was important to us that we maintained our competitive advantage… .”

That fight led McDonald’s to see a 1.8 percent rise in sales at restaurants open at least 13 months in the U.S., but that’s far slower than the company has reported in recent quarters. The metric is a key gauge of restaurant health because it excludes results from new stores.

McDonald’s is the biggest restaurant company yet to report that the slowdown affected its financial results, but it’s far from alone. Both Starbucks and the parent of Dunkin’ Donuts noted slowing traffic growth when they reported earnings last week.