American consumers pulled back on spending at the close of last year as the government headed into a shutdown and the stock market sent share prices plummeting.

Retail sales fell a seasonally adjusted 1.2 percent from a month earlier to $505.8 billion, the Commerce Department said Thursday. Not counting sales of cars and light trucks, sales fell a steeper 1.8 percent.

Economists had been expecting a 0.1 percent boost in the overall number and a gain of 0.15 percent for the ex-autos figure.

The Commerce Department’s retail sales figure is an important component of Gross Domestic Product. It measures online purchases, purchases at stores, and spending at restaurants.

Part of the decline can be attributed to gasoline prices, which fell sharply in December. This brought down spending at gas stations by 5.1 percent. Excluding spending on gasoline and autos, retail sales declined 0.9%, the worst since 2014.

But sales were weaker at department stores, falling 3.3 percent, bookstores, and sporting goods stores. Sales at health and personal care stores dropped 2 percent. Restaurant sales declined 0.7 percent for a second consecutive month.

The sales slump does not appear to be due to online retailers disrupting brick-and-mortars. Sales by online retailers, which the government refers to as “nonstores,” fell 3.9 percent.

Compared with the prior December, retail sales were up just 2.3 percent. That could mean that GDP growth for the fourth quarter will be weaker than expected.

One bright spot was vehicle sales, a category that had struggled earlier in the year and is not typically given a boost by the holiday shopping. season. Auto sales rose 1.1 percent for the month and were up 3.7 percent compared with a year earlier.

The ex-autos decline of 1.8 percent in the sharpest decline since December 2008, when the country was in a recession and staggering from the near collapse of the financial system.

The December retail sales report was released Thursday, several weeks later than typical due to the government shutdown.

Retail sales can be volatile month-to-month. The stock market has mounted a strong recovery since hitting a bottom after Christmas and the government has re-opened, with the Trump administration and Congress reportedly having struck an agreement to avoid another shutdown. That could mean sales bounce back.