The trade deficit fell 0.6 percent in July to a seasonally adjusted $40.5 billion, from $40.8 billion in June, the Commerce Department said Thursday.
Exports climbed 0.9 percent to a record $198 billion. Imports also rose, climbing 0.7 percent to $238.6 billion, as shipments of food, beverages and autos from abroad increased.
Imports of oil products increased, but rising domestic production reduced the trade deficit in petroleum to its lowest in more than five years.
The trade deficit with China rose to a monthly record of $30.9 billion.
The combination of rising imports and exports suggest increased spending by consumers and businesses, which generally points to the possibility of solid economic growth in the second half of 2014.
"The decline in the trade deficit is encouraging and echoes what the activity surveys are telling us, namely that economic growth remains strong," said Paul Ashworth, chief U.S. economist at Capital Economics. Ashworth projects that the economy is on track to expand at an annualized clip of at least 3 percent in the third quarter.
Trade deficits subtract from gross domestic product, so a narrowing deficit should help boost growth. The trade deficit's drag on the economy lessened in the April-June quarter, after having hurt GDP in the first three months of the year.
Exports fell 9.2 percent in the first quarter, likely because of slower growth in Europe and China. At the same time, imports rose and the resulting gap contributed to the economy shrinking at an annualized rate of 2.1 percent in the first three months.
Overall, the trade deficit lowered growth by 1.6 percentage points in the first quarter. The economy shrank at a 2.1 percent seasonally adjusted annual rate, the worst showing since the recession.
Exports rose in June to $195.9 billion, the previous record high. Imports shrank 1.2 percent that month to $237.4 billion. The lower trade deficit figures helped reduce the drag on economic growth in the second quarter, as the economy improved at an annualized clip of 4.2 percent.
Still, the trade deficit has widened in the first seven months of this year to $295.3 billion, up from $282.2 billion during the same period in 2013. Imports have risen faster than exports.
In 2013, the trade deficit declined by 11.4 percent. That reflected in part a boom in U.S. energy production that cut into America's dependence on foreign oil, while boosting U.S. petroleum exports to a record high.
The nation's trade balance in oil has continued to improve this year. The U.S. had a petroleum trade deficit of $119.8 billion in the first seven months of this year, down from $144.7 billion last year.