The U.S. economy grew at a strong 4.2 percent annual rate in the April-June quarter, the best showing in nearly four years, as growth stayed on track to produce its strongest gain in more than a decade. Strength in business investment offset slightly slower consumer spending.

The Commerce Department on Wednesday revised up its estimate of growth for last quarter from an initial estimate of a 4.1 percent annual rate. The second quarter marked a sharp improvement from a 2.2 percent gain in the January-March period, though some of the strength last quarter came from temporary factors, including a surge in U.S exports before tariffs were to take effect.

Economists expect growth to slow to a still solid 3 percent annual rate the rest of the year, resulting in full-year growth of 3 percent for 2018, which would be the best performance since 2005, two years before the Great Recession began.

The 4.2 percent annual growth that the government estimated for last quarter is the strongest figure since a 4.3 percent annual gain in the third quarter of 2014. The expectation of 3 percent growth for the entire year would be up from gains of 1.6 percent in 2016 and 2.2 percent last year.

Since the recovery began in mid-2009, growth has been sub-part, with annual gains averaging just 2.2 percent, making this the weakest recovery in the post-war period.

President Donald Trump often pointed to that fact during the 2016 presidential campaign to attack the economic record of the Obama administration He has touted the recent pickup in GDP as evidence that his economic program of tax cuts, deregulation and tougher enforcement of trade agreements is working. Last month, Trump proclaimed that the GDP figure showed that the United States was now the “economy envy of the world.”

While forecasting solid growth around 3 percent this year, economists contend that this performance is being pumped up by the $1.5 trillion tax cut Trump pushed through Congress last year along with increased government spending. Most analysts say they think those factors will begin to fade starting next year and that by 2020, growth may even slow enough to edge the economy close to a possible recession.

The Trump administration rejects that outlook, arguing that its policies will unleash an economic boom that will produce annual growth of 3 percent or better over the next decade.

Treasury Secretary Steven Mnuchin, in a CNBC interview Tuesday, pointed to the solid GDP performance in the spring as evidence that the administration is fulfilling Trump’s campaign promises regarding the economy.

“We are delivering on what was the president’s economic agenda about creating growth,” Mnuchin said.

Wednesday’s GDP report showed that consumer spending, which accounts for about 70 percent of economic activity, expanded at a strong annual rate of 3.8 percent in the second quarter, down slightly from an initial estimate of 4 percent growth in consumer spending. But that downward revision was outweighed by other factors including stronger business investment, which grew at a 6.2 percent rate, driven by spending on such items as computer software.

Other sources of strength were less growth in imports, which subtract from GDP, and faster growth in government spending at the federal and state and local levels.

© The Associated Press. All rights reserved.