US imports of goods and services rose to the highest on record in October, widening the trade gap to its highest level in nine months, according to government data released Tuesday.

The trade deficit for the month was pushed by rising oil prices, as well as record imports from China ahead of the holiday shopping season, the US Commerce Department said in its monthly report.

Boosted by a weaker US dollar, the October trade gap rose 8.6 percent compared to September, to $48.7 billion, the highest since January, surpassing analyst expectations for an increase of only 5.6 percent.

Imports rose 1.6 percent over September to $244.6 billion, seasonally adjusted, the highest since the Commerce Department began publishing the statistic in 1992.

Exports were unchanged at $195.9 billion, but services exports were also the highest on record at $65.6 billion.

The mounting trade deficit comes the administration of President Donald Trump enters the latter stages of fraught negotiations with Mexico and Canada to revamp the North American Free Trade Agreement (NAFTA).

Trump took office on a nationalist economic agenda, pledging to bring down the trade deficit by canceling or renegotiating trade pacts and aggressively policing the export practices of major trading partners.

It was the second straight month in which the US trade gap widened, driven in part by goods imported from China of $48.2 billion, an all-time high, bringing the US trade deficit with that country to $31.9 billion.

Exports to China, meanwhile, were the highest in almost four years, at $13 billion.

Imports of goods also increased from Mexico to $28.7 billion and from the European Union to $39.4 billion. Exports of goods to Mexico rose $22.1 billion for the month, a three-year high.

Imports of mobile phones rose $300 million as did transportation services.

Average prices for imported crude oil also hit a two-year high at $47.26 a barrel, moving the value of crude imports up by $1.5 billion.