WASHINGTON, – The U.S. economy slowed less than expected in the third quarter as a tariff-related drop in soybean exports was partially offset by the strongest consumer spending in nearly four years and a surge in inventory investment.

Gross domestic product increased at a 3.5 percent annualized rate also supported by solid government spending, the Commerce Department said on Friday in its first estimate of third-quarter GDP growth. While that was a slowdown from a 4.2 percent pace in the second quarter, it still exceeded the economy’s growth potential, which economists put at 2 percent.

Compared to the third quarter of 2017, the economy grew 3.0 percent, the best performance since the second quarter of 2015, keeping it on track to hit the Trump administration’s 3 percent growth target this year.

The economic expansion, now in its ninth year, is the second longest on record. Economists polled by Reuters had forecast GDP expanding at a 3.3 percent pace in the third quarter.

The economy is underpinned by a $1.5 trillion tax cut and increased government spending. The fiscal stimulus is part of measures adopted by President Donald Trump’s administration to boost annual growth to 3 percent on a sustainable basis.

Yet the government is also locked in a bitter trade war with China as well as trade disputes with other trade partners and the last quarter’s slowdown mostly reflected the impact of Beijing’s retaliatory tariffs on U.S. exports, including soybeans.

Farmers front-loaded shipments to China before the tariffs took effect in early July, boosting second-quarter growth. Since then, soybean exports have declined every month, increasing the trade deficit. There were also decreases in exports of petroleum and non-automative capital goods. Strong domestic demand, however, sucked in imports of consumer goods and motor vehicles.

The widening trade gap chopped off 1.78 percentage points from GDP growth in the third quarter. That was the most since the second quarter of 1985 and reversed the 1.22 percentage point contribution in the April-June period.

Some of the rebound in imports reflected a rush by businesses to stockpile before U.S. import duties, mostly on Chinese goods, came into effect. Imports are a drag on GDP growth. But some of the imports likely ended up in warehouses, adding to the stockpile of inventory, which adds to GDP.

Inventories increased at a $76.3 billion rate after declining at a $36.8 billion pace in the second quarter. As a result, inventory investment added 2.07 percentage points to GDP growth, the biggest contribution since the first quarter of 2015, after slicing off 1.1 percentage points from output in the second quarter.

Excluding the effects of trade and inventories, GDP grew at a 3.1 percent rate in the third quarter compared to a 4.0 percent pace in April-June.

Solid third-quarter growth is expected to keep the Federal Reserve on course to raise interest rates again in December, despite a recent tightening in financial market conditions brought about by a stock market sell-off and a rise in U.S. Treasury yields.

The Fed raised rates in September for the third time this year and removed a reference to monetary policy remaining “accommodative” from its policy statement.

Growth in consumer spending, which accounts for more than two-thirds of U.S. economic activity, increased at a 4.0 percent rate in the third quarter. That was the fastest pace since the fourth quarter of 2014 and followed a 3.8 percent pace of increase in the second quarter.

Consumption is being supported in part by a tightening labor market, characterized by an unemployment rate that is at a near 49-year low of 3.7 percent.

But business spending on equipment stalled in the third quarter and residential investment contracted for a third straight quarter, adding to growing headwinds for the economy.

Higher interest rates are pressuring the housing market, businesses are struggling to find workers and the import tariffs are increasing manufacturing costs for companies, such as Caterpillar Inc (CAT.N), 3M Co (MMM.N) and Ford Motor Co (F.N).