WASHINGTON (AP) -- The U.S. trade deficit narrowed in March as exports rebounded to the second highest level on record, led by strong gains in sales of aircraft, autos and farm goods.

The deficit declined to $40.4 billion, down 3.6% from a revised February imbalance of $41.9 billion, the Commerce Department reported Tuesday. The February deficit had been the biggest trade gap in five months.

U.S. exports rose 2.1% to $193.9 billion with exports to Canada and South Korea hitting all-time highs. Imports also rose but by a slower 1.1%  to $234.3 billion, reflecting increased shipments of cell phones, clothing and other consumer goods and increased demand for heavy machinery and other capital goods.

A smaller trade deficit can boost growth because it means U.S. companies are earning more on their overseas sales.

In 2013, the trade deficit narrowed 11.2% to $474.9 billion, helping provide a small boost to overall economic growth.

Analysts are looking for a similar small contribution to growth from a narrowing trade deficit this year. They forecast that an improving global economy will boost demand for U.S. exports. However, imports are also expected to rise as stronger U.S. activity increases consumer spending on foreign products.

For the first three months of this year, trade was a big negative on overall growth, subtracting 0.8 percentage point in the first quarter as exports fell sharply compared to the final three months of last year.

That translated into weak overall growth in the gross domestic product of just 0.1% in the January-March quarter. Economists expect GDP growth will rebound in the second quarter to a much stronger rate of 3% or better as exports recover from their first-quarter decline and other parts of the economy gain momentum as warmer weather spurs activity following the harsh winter.

While the trade deficit narrowed in March, economists said the improvement will not be enough to keep the government from revising its first-quarter growth estimate down into negative territory.

But Paul Ashworth, chief U.S. economist at Capital Economics, said the important development was that the economy was showing many signs of a rebound in the current quarter.

"The monthly data clearly show a big resurgence in activity and employment over the past couple of months, confirming that the earlier weakness was weather-related," he said.

Many economists expect the trade deficit will keep narrowing this year as exports, helped by an energy production boom in the United States, grow faster than imports.

A domestic energy boom has boosted exports and reduced America's dependence on foreign oil. U.S. petroleum exports rose to an all-time high of $137.2 billion last year, up 11% from 2012. Energy imports fell 10.9% to $369.4 billion as domestic production took the place of some imports.

For March, energy exports increased 3% to $11.4 billion while petroleum imports dropped 3.4% to $30 billion. For the first three months of this year, petroleum exports are up 7% while imports are down 3.4%.

The deficit with China dropped 2.2% in March to $20.4 billion but remained the largest imbalance with any country. The big trade gap with China has kept pressure on the Obama administration and Congress to take a tougher line on what critics see as unfair trade practices by China to gain trade advantages.

The deficit with the European Union jumped 26.7% to $11.5 billion although U.S. exports to Germany, the largest economy in Europe, climbed to the highest level since October 2008.

The trade deficit with Canada was up 3.7% to $2.2 billion even though U.S. exports to Canada hit a record high.

Critics say Beijing is manipulating its currency to keep it undervalued against the U.S. dollar. That makes Chinese goods cheaper in the United States and more attractive to American consumers and American products more expensive in China.

The Obama administration is lobbying Congress to pass the "fast track" authority it will need to speed approval of two big trade agreements it is currently negotiating, but election-year politics are complicating the White House effort.

The administration is negotiating one trade agreement with Japan and 10 other Pacific nations. The other agreement would be a trans-Atlantic deal with the 28-nation European Union.

The deals would lower trade barriers and are seen by supporters as a good way to boost U.S. export sales. But critics, including many labor unions, contend that the agreements will open American workers to greater competition and actually end up costing U.S. jobs.

The negotiations on the Trans-Pacific Partnership were a central issue in Obama's visit to Tokyo last month.

While Obama was in Tokyo, U.S. officials said that the two countries had narrowed their differences on market access issues related to agriculture and automobiles, two key sectors which have deadlocked the talks.

The 12-nation trade pact is seen as a key component of the Obama administration's efforts to assert U.S. influence in Asia.