Retailers held on to sales gains in March despite the recent spike in gas prices, according to government data released Wednesday.

The Commerce Department reported that shoppers pulled out their wallets for discretionary purchases such as electronics, furniture and apparel — which many economists interpreted as a signal of consumer health. Excluding volatile categories such as autos, gas and building materials, retailers posted a 0.4 percent gain in March compared with the previous month.

But there were also some warning signs: That increase was the smallest this year. Sales at gas stations jumped 2.6 percent, one of the biggest spikes of any category. Spending on cars and at online retailers and department stores all declined.

“There’s a clear slowdown in the growth in spending in March,” said Steve Blitz, senior economist for ITG Investment Research. “The devil and the angel are in the detail.”

Some economists have been worried that the recent runup in fuel prices could force consumers to reduce spending in other areas — a move that could set back the nation’s economic recovery. Though gas has yet to surpass its recent high in 2008 of $4.11, a recent Gallup poll found that consumers expect prices at the pump to surpass that this year. Meanwhile, 71 percent of shoppers surveyed by consulting firm Deloitte said that higher gas prices would cause them to trim their budgets.

But so far, there has been more frustration than frugality. Clothing stores rang up a 0.6 percent increase in March sales compared with the previous month. Sales at electronics and appliance stores jumped 2.1 percent, perhaps buoyed by the release of the iPad 2. And home furnishings sales, which have languished since the collapse of the real estate market, soared 3.6 percent.

“This is a good report since it indicates consumers are still spending despite all the problems they are facing,” said Chris G. Christopher Jr., senior principal economist at IHS Global Insight.

Some of the strength in consumer spending can be attributed to the broader recovery. The economy added 216,000 jobs in March, according to government data, and the unemployment rate ticked down to 8.8 percent. That could be making consumers feel more comfortable about dipping into their savings. In addition, this year’s payroll tax cut might also have padded shoppers’ pocketbooks.

But economists and retailers are eyeing April as a more accurate litmus test of consumers’ health. Several technical quirks might be clouding last month’s numbers: Snowy weather in January might have pushed many retail sales into February, making results that month seem stronger. Meanwhile, this year’s late Easter might be throwing off calculations for March.

Even more important will be the length of time that gas prices remain elevated. Though shoppers have absorbed the spike for now, many will eventually have to make tough choices.

“If there was nothing else going on in the world, then you could just end the story right there,” Blitz said. “March is a little bit of a caution flag.”