The U.S. economy gathered momentum during the first full quarter with President Trump in charge.

Economic growth accelerated to an annual rate of 2.6% from April through June, the government said Friday. That was about what economists had expected.

Second-quarter growth more than doubled the sluggish pace from the first three months of the year. First-quarter economic growth was revised down to 1.2%.

The economy gained steam in part because of stronger consumer spending, according to the Commerce Department. Helped by the strong job market, personal spending grew at a 2.8% pace, faster than in the first quarter.

That's a relief because despite stronger consumer confidence, Americans have been unwilling to spend more.

The economy also benefited during the second quarter from increased federal government spending.

"The real economy remains in good shape," Andrew Hunter, an economist at Capital Economics, wrote in a report.

Related: Fed keeps rates steady amid inflation concerns

Growth was held back by the housing market, though. Residential Investment, which includes houses and apartments, tumbled by nearly 7% last quarter. Exports also slowed.

Overall economic growth is well short of 4%, the promise Trump made as a candidate, but it is getting closer to the moderate goal of 3% that he has set since taking office.

Trump's election and promises of massive tax cuts and infrastructure spending lifted expectations on Wall Street and among economists of faster growth. But Trump hasn't been able to get his economic agenda through Congress, so those expectations have been dialed back.

Last week, the International Monetary Fund lowered its U.S. growth forecast for this year and next because of "uncertainty" over the timing and size of Trump's policies. And the U.S. dollar, which rallied after the election, has retreated sharply in recent months.