Both exports and imports reached new highs in 2017, as New Zealand earned more from agricultural products and bought more cars and computers, the country's statistics department Stats NZ said on Tuesday.

China was New Zealand's top trading partner in 2017, Stats NZ said. Exports to China were valued at NZ$12 billion ($8.8 billion), or 22 percent of New Zealand's total exports, while imports from China were valued at NZ$10.9 billion ($8 billion), or 19 percent of New Zealand's total imports, statistics show.

"China overtook Australia as our top export market in 2013 and has remained at the top every calendar year since," international statistics manager Tehseen Islam said in a statement.

"The gap between the top two markets is now wider than it's been at any time since then," Islam said.

Annual exports were valued at NZ$53.7 billion for the year ended December 2017, up 11 percent from 2016, led by dairy products, meat, logs, wood, and wood articles, he said.

Imports for the December 2017 year were up NZ$4.9 billion to NZ$56.5 billion, led by mechanical machinery and equipment, such as aircraft parts, computers, vehicles and parts and accessories, statistics show.

New Zealand's total two-way goods trade (exports plus imports) for the year ended December 2017 was worth NZ$110 billion, up 10 percent from 2016, Stats NZ said, adding that annual two-way goods trade has remained above NZ$100 billion for the last four years.

For the year ended December 2017, there was an annual trade deficit of NZ$2.8 billion, or 5.3 percent of exports, which was smaller than the NZ$3.1 billion deficit, or 6.5 percent of exports, in 2016.