WASHINGTON (AP) — The U.S. economy grew at a robust annual rate of 3.5 percent in the July-September quarter as the strongest burst of consumer spending in nearly four years helped offset a sharp drag from trade.

The Commerce Department said Friday that the third quarter’s gross domestic product, the country’s total output of goods and services, followed an even stronger 4.2 percent rate of growth in the second quarter. The two quarters marked the strongest consecutive quarters of growth since 2014.

The result was slightly higher than many economists had been projecting. It was certain to be cited by President Donald Trump as evidence his economic policies are working. But some private economists worry that the recent stock market declines could be a warning signal of a coming slowdown.

The GDP report along with next week’s unemployment report for October are the last major looks at the economy before voters go to the polls in the mid-term elections.

For this year, economists are projecting the momentum built up should result in growth of 3 percent, the best annual showing in 13 years. But they believe the impact of Trump’s trade war with China and rising interest rates will slow growth in 2019 to around 2.4 percent, with a further decline to under 2 percent in 2020.

“I think we will see a significant slowdown, in part because economic growth has been raised to an artificially high level by the tax cuts,” said Sung Won Sohn, chief economist at SS Economics in Los Angeles.

Trump in recent weeks has accelerated his attacks on the Federal Reserve for raising interest rates, contending that the higher rates by slowing the economy will work against his efforts to speed up growth through the $1.5 trillion tax cut package Trump got Congress to pass last year.

“Every time we do something great, he raises interest rates,” Trump said in an interview this week with the Wall Street Journal in which he again said he viewed the Fed as the “biggest risk” facing the economy “because I think interest rates are being raised too quickly.”

The central bank has raised rates three times this year and signaled it will raise rates one more time this year and expect to raise rates three times in 2019. Those moves are being made to ensure that tight labor markets, with unemployment at a 49-year low of 3.7 percent, and strong growth don’t trigger unwanted inflation.

The GDP report Friday was the government’s first of three reviews of overall economic activity for the July-September period.

The report showed that consumer spending, which accounts for 70 percent of economic activity, surged at an annual rate of 4 percent in the third quarter, even better than the 3.8 percent gain in the second quarter and the best showing since last 2014.

Trade, which had boosted second quarter growth by 1.2 percentage points, shaved 1.8 percentage points off growth in the third quarter. Exports, which had surged at a 9.3 percent rate in the second quarter, fell at a 3.5 percent rate in the third quarter. Analysts had forecast this turn-around, saying it reflected the surge in exports of goods such as soybeans in the spring as producers tried to beat the higher tariffs being imposed by China in retaliation for Trump’s tariffs.

Another big swing factor in the third quarter was business restocking of their shelves. Inventories had trimmed 1 percentage point off growth in the second quarter but boosted growth by 2 percentage points in the third quarter.

Housing continued to be a drag, falling for a third straight quarter. Business investment, which had surged at an 8.7 percent rage in the second quarter, slowed to a small 0.8 percent gain the third quarter.