WASHINGTON — The U.S. economy slowed in the spring, and most analysts expect it to weaken further in the months ahead. Yet the main driver of growth — consumer spending — remains vigorous enough to keep the economy growing steadily if still modestly.

Spending by households, which accounts for about 70% of economic growth, accelerated in the April-June quarter to its fastest pace in nearly five years. Eventually, President Donald Trump's tariffs on hundreds of billions of dollars in imports could bring higher prices and lower consumer spending. But for now, household spending remains a vital pillar of the economy.

The nation's gross domestic product — the broadest gauge of economic health — grew at a moderate 2% annual rate in the April-June quarter, the Commerce Department reported Thursday. That was down from a 3.1% growth rate in the first quarter, but it would have been much weaker without a burst of consumer demand.

Economists generally expect growth to slow to a 2% annual rate or less for the rest of the year. But most think consumer spending will be enough to offset headwinds ranging from a slowing global economy to growing uncertainties caused by Trump's trade war with China.

In the April-June period, consumer spending shot up to an annual rate of 4.7%, the best showing since the final quarter of 2014. The surge followed two weak quarters for spending as car sales sank and households grew cautious after a stock market fall and a partial shutdown of the government.

At the same time, business investment is weakening in the face of the uncertainties created by the taxes that Trump has imposed on numerous imports — goods that many American businesses rely upon.

Gus Faucher, chief economist at PNC Financial, said he expects the trade war to begin to weigh on consumers in the second half of this year as some of Trump's additional tariffs on Chinese products take effect Sunday and others on Dec. 15. In addition, higher tariffs on a separate group of Chinese products are to take effect Oct. 1.