The annual deficit in the year to July was $3.21 billion versus $3.65 billion in the year to June.
Exports rose 11% on the year to $4.7 billion.
The trade surplus of $292 million in April.
Exports were bolstered by a $267 million drilling platform.
Statistics NZ said the country had a merchandise trade surplus of $8.1 million in January.
The annual trade deficit was $2.41 billion.
The Meeting Place of Intelligent Business