WASHINGTON — The U.S. economy rebounded sharply in the spring, growing at the fastest pace in more than two years amid brisk consumer spending on autos and other goods.

The gross domestic product, the broadest measure of economic health, grew at an annual rate of 3 percent in the April-June quarter, the Commerce Department reported Wednesday. It was the best showing since a 3.2 percent gain in the first quarter of 2015.

The result is a healthy upward revision from the government’s initial estimate of 2.6 percent growth in the second quarter. The growth rate in the January-March quarter was a lackluster 1.2 percent.

Paul Ashworth, chief U.S. economist at Capital Economics, said he believed that the strength in consumer spending should result in an “even stronger hand-off” for growth going into the current quarter. He predicted GDP would grow close to 3 percent this quarter.

President Donald Trump hailed the latest figures, declaring “we are really on our way.” Trump said if the economy is able to sustain growth at a 3 percent rate, it would create 12 million new jobs and $10 trillion in new economic activity over the next decade.

“I happen to be one that thinks we can go much higher than 3 percent. There is no reason why we shouldn’t,” Trump told a crowd in Missouri where he was campaigning for support for the administration’s tax plan that would cut rates for individuals and businesses.

During last year’s campaign, Trump pledged to boost economic growth to 4 percent or better.

The budget the president released in May projects GDP growth will rise to 3 percent over the next four years and remain at that level for the rest of the decade. However, private economists and the nonpartisan Congressional Budget Office believe that forecast is unrealistic. CBO is forecasting average growth of just 1.9 percent over the next decade.

For the second quarter, the government estimated that consumer spending grew at a 3.3 percent rate, the best showing in a year and up from an initial estimate of 2.8 percent growth. Much of the strength came from a sharp upward revision in spending on autos, which the government initially estimated as declining in the spring.

Investment by businesses also improved to growth of 6.9 percent, reflecting higher spending on structures, equipment and intellectual property.

Spending by governments, which had grown 0.7 percent in the initial estimate, was revised to a decline at a 0.3 percent rate. The downgrade reflects a 1.7 percent fall in spending by state and local governments.

This was the second of three estimates the government will provide for second quarter growth. Even with the upward revision, the weak start to the year means that growth over the past six months has averaged 2.1 percent, the same modest pace seen for the recovery that began in mid-2009.

Many economists had been forecasting growth in the current July-September quarter would be around 3 percent. Some are now saying that the devastation from Hurricane Harvey could shave about a half-percentage point off growth this quarter. However, analysts believe the pace of growth will bounce back once the rebuilding begins and oil refineries get back to full production, bringing down prices.

For the entire year, Mark Zandi, chief economist at Moody’s Analytics, is forecasting growth of 2.1 percent. That would mark an improvement over last year when the economy grew a meager 1.5 percent, the poorest showing since 2009 when GDP shrank by 2.9 percent.

Zandi is forecasting that growth in 2018 will be an even stronger 2.8 percent. But he said 0.4 percentage point of that forecast reflects an assumption that the Trump administration will win a tax cut package that will take effect in early 2018. The economy will also be boosted by higher spending on the military and infrastructure projects, he said.

“For the first time since the Great Recession ended in mid-2009, the economy is not facing any significant headwinds,” Zandi said.