A container ship at the Port of Oakland in Oakland, California.

The U.S. trade deficit widened more than expected in December, hitting its highest level since 2008 as robust domestic demand pushed imports to a record high.

The Commerce Department said on Tuesday the trade gap increased 5.3 percent to $53.1 billion. That was the highest level since October 2008 and followed a slightly upwardly revised $50.4 billion shortfall in November.

Economists polled by Reuters had forecast the trade deficit rising to $52.0 billion in December after a previously reported $50.5 billion in the prior month. Part of the rise in the trade gap in December reflected commodity price increases.

The deficit surged 12.1 percent to $566.0 billion in 2017, the highest since 2008. The politically sensitive U.S.-China trade deficit increased 8.1 percent to a record $375.2 billion last year.

U.S. President Donald Trump has vowed to shrink the trade gap through his "America First" trade policies, which aim to shut out more unfairly traded imports and renegotiate past U.S. free trade agreements.

Trump has repeatedly threatened to terminate the North American Free Trade Agreement unless the pact linking Canada, Mexico and the United States can be changed to terms more favorable to Washington. And his administration has launched an investigation into China's intellectual property practices that could lead to major new trade sanctions on Beijing.

The surge in the December trade deficit was flagged by an advanced goods trade deficit report published in late January. When adjusted for inflation, the trade deficit increased to $68.4 billion from $66.5 billion in November.

The jump in the so-called real trade deficit at the end of the year puts trade on course to be a drag on gross domestic product in the first quarter. Trade subtracted 1.13 percentage point from GDP growth in the final three months of 2017.

The economy grew at a 2.6 percent annualized rate during that period, helping to lift growth in 2017 to 2.3 percent from 1.5 percent in 2016.