WASHINGTON — The U.S. economy grew at a 3.5 percent annual rate in the July-September quarter, the fastest pace in two years and more than the government had previously estimated. But the growth spurt isn’t expected to last.

The gain in the gross domestic product – the economy’s total output of goods and services – came from consumer spending, business investment and the government sector, the Commerce Department said Thursday. The government previously estimated last quarter’s annual growth rate at 3.2 percent.

Thursday’s GDP report “paints a picture of a healthy consumer, likely fueled by ongoing gains in employment, modest increases in wages, and solid balance sheets,” Michael Gapen of Barclays.

The economy’s acceleration last quarter marked a sharp pickup from the tepid annual growth of 0.8 percent in the first quarter and 1.4 percent in the second. Still, growth is expected to slow to a roughly 1.5 percent annual rate in the October-December quarter, reflecting in part less consumer spending and less business stockpiling.

Growth for the entire year, economists say, is likely to be around 1.5 percent. That would be down from 2015 and would be the weakest performance since the economy shrank 2.8 percent in 2009 at the depths of the worst economic downturn since the 1930s. The recovery began in mid-2009, but growth has averaged just over 2 percent.