WASHINGTON – Retail sales rose less than projected in June as demand cooled at building materials outlets and restaurants, underscoring a second-quarter slowdown in the U.S. economy.

The 0.4 percent gain followed a 0.5 percent increase in May that was less than previously reported, Commerce Department figures showed Monday. The median forecast of 82 economists surveyed by Bloomberg called for a 0.8 percent advance. Sales were unchanged excluding the biggest jump in automobile purchases since November.

The figures show consumer spending, the biggest part of the economy, may take time to accelerate as Americans stay frugal and rebuild savings. At the same time, cheaper borrowing costs, household wealth backed by home and stock prices and an improving job market are helping to sustain demand for big-ticket items such as motor vehicles.

“Consumers are spending cautiously,” Ryan Sweet, a senior economist at Moody’s Analytics Inc. in West Chester, Pa., said before the report. “There is still some lingering uncertainty, mortgage rates have ticked up and the stock market has been volatile. Consumer spending is going to improve in fits and starts. We’ll start to see spending pick up late this year.”

Receipts at restaurants and bars decreased 1.2 percent in June, the most since February 2008. Sales dropped 2.2 percent at building materials outlets, the most since May 2012.

Eight of 13 major categories showed an increase last month, led by a 1.8 percent gain at automobile dealers. Purchases rose 2.4 percent at furniture and home furnishing chains, the most since May 2012.

Retail sales excluding autos and gasoline unexpectedly fell 0.1 percent.

Service-station sales rose 0.7 percent after a 0.4 percent increase. Costlier gasoline in early June probably lifted receipts at filling stations. The Commerce Department’s retail sales data aren’t adjusted for changes in prices.

A gallon of regular gasoline at the pump reached $3.63 on June 9, before easing in the next few weeks to a five-month low of $3.47 on July 7, according to AAA, the biggest U.S. motoring group. Retail gasoline has again reversed course, having risen four days in a row as crude oil costs surged and refinery units shut down for repairs.

Purchases excluding autos, gasoline and building materials, which render the figures used to calculate gross domestic product, rose 0.1 percent after a 0.2 percent increase in the previous month.

Automobile demand remains a bright spot as Americans replace older vehicles. Cars and light trucks sold in June at a 15.89 million annual rate, the fastest since November 2007, according to data from Ward’s Automotive Group. Attractive financing offers and steady hiring are also helping generate more industry sales.

Ford Motor Co. and General Motors Co., makers of the best- selling big pickups in the United States, reported June sales that beat analysts’ estimates. Low borrowing costs and rising consumer wealth should continue to support spending, according to Jenny Lin, Dearborn, Mich.-based Ford’s senior U.S. economist.

Household wealth has been boosted by a rally in the stock market and higher property values.

Home prices in the 12 months that ended in April rose by the most in more than seven years, according to the S&P/Case-Shiller index of property values. The Standard & Poor’s 500 Index last week reached a record high.

Costco Wholesale Corp., the largest U.S. warehouse-club chain, reported a 6 percent gain in June sales at U.S. stores open at least a year, more than analysts’ projections.

The world’s largest economy will expand at a 2.3 percent annualized pace in the third quarter after cooling to a projected 1.6 percent rate in the April through June period, according to the median forecast in a Bloomberg survey from July 5 to July 10. Household spending also will pick up, economists forecast.

Fed Chairman Ben Bernanke, in testimony to Congress this week, may shed more light on the central bank’s view of the economy and how policymakers may begin scaling back $85 billion in monthly bond purchases.

The United States needs “highly accommodative” monetary policy for the foreseeable future, Bernanke said last week.