Containers are unloaded from the Eimskip ship Bruarfoss in Portland, Maine.

The U.S. trade deficit fell sharply in June as exports increased to their highest level in 2-1/2 years, a positive development for the economy.

The Commerce Department said on Friday the trade gap decreased 5.9 percent to $43.6 billion, the lowest level since October 2016. May's trade deficit was revised slightly down to $46.4 billion from the previously reported $46.5 billion.

Economists polled by Reuters had forecast the trade shortfall narrowing to $45.0 billion in June.

When adjusted for inflation, the trade deficit fell to $61.0 billion from $62.8 billion in May. Real goods exports surged to an all-time high of $126.9 billion in June, buoyed by record high petroleum exports.

The government reported last Friday that trade contributed almost two-tenths of a percentage point to the economy's 2.6 percent annualized growth pace in the second quarter.

In June, exports of goods and services increased 1.2 percent to $194.4 billion, the highest level since December 2014. There were increases in exports of capital goods, food and motor vehicles. Exports to China fell 4.7 percent.

Imports of goods and services slipped 0.2 percent to $238.0 billion in June. There were decreases in imports of industrial supplies and materials. Imports of cell phones and other household goods fell $0.9 billion, accounting for the bulk of the $0.7 billion decrease in consumer goods imports.

Imports of goods from China increased 1.2 percent. The politically sensitive U.S.-China trade deficit increased 3.1 percent to $32.6 billion in June.