The U.S. trade deficit widened to its highest level in two years in April as imports hit a record high, suggesting trade could be a drag on second-quarter growth.

The Commerce Department said on Wednesday the trade gap increased 6.9 percent to $47.2 billion. That was the largest since April 2012 and followed March's revised $44.2 billion gap.

Economists polled by Reuters had expected the deficit to widen only to $40.8 billion from a previously reported $40.4 billion shortfall. The government also published its annual benchmark revisions with Wednesday's data.

When adjusted for inflation, the deficit increased to $53.8 billion from $50.9 billion in March.

Trade subtracted almost a percentage point from first-quarter gross domestic product. The economy contracted at a 1.0 percent annual pace in the first three months of the year.

Imports increased 1.2 percent to an all-time high of $240.6 billion in April. Imports of automobiles, capital goods, food and consumer goods all hit record highs in April.

The trade deficit with the European Union was the largest on record, as was the gap with Germany.

Imports from South Korea also touched a record high, while Chinese imports rose 16.3 percent.

That pushed up the politically sensitive trade gap with China to $27.3 billion from $20.4 billion in March.

Exports slipped 0.2 percent to $193.3 billion.