WASHINGTON—The economy powered ahead in the third quarter, driven by robust consumer and government spending, though Friday’s report included warning signs that the business sector faces turbulence that could hold back the expansion in the months ahead.

Gross domestic product—a measure of how much the U.S. produces in goods and services—grew at a 3.5% annual rate from July through September to $18.7 trillion, adjusted for inflation, the Commerce Department said Friday. That came after a 4.2% growth rate in the second quarter and stands as fresh evidence that growth has picked up from subpar levels closer to 2% that had prevailed for much of the long-running U.S. expansion since 2009.

However, signaling unease about the emerging outlook, stocks fell Friday, with the Dow Jones Industrial Average shedding 1.19% and the Standard & Poor’s 500-stock index dropping 1.73%.

Third-quarter corporate earnings have been largely positive, with some 80% of reporting S&P 500 firms posting profits that exceeded Wall Street’s expectations. But sales performance has been more mixed, with more than a third of firms so far missing revenue projections. It is a trend that amplifies some investors’ concern that U.S. economic growth may have peaked earlier this year.

Consumer spending is being powered by plentiful jobs. The unemployment rate fell in September to its lowest level since 1969, meaning more income in household pocketbooks, and tax cuts have added to purchasing power. That showed up in the report in the form of additional spending on everything from restaurants to recreational goods.