The end of 2016 was better than the start for exports.

Led by medical instruments, machinery, electrical equipment and vehicle components, exports reached $5 billion for the fourth quarter to match results in the same quarter of 2015, state officials said.

Minnesota was hit with challenges throughout last year, including the strong U.S. dollar, a recovering iron industry and a decline in demand from key trading partners.

Still, the quarter showed a recovery from lower exports year over year in the first three quarters of the year.

The exports of medical instruments, machinery, electrical equipment and vehicles/components contributed $2.7 billion in trade, even as international sales for all four declined somewhat in the final months of 2016.

Also growing during the quarter were Minnesota dairy products (up 74 percent to $31 million), goods made of base metals ($30 million, up 46 percent), baked goods ($30 million, up 45 percent) and dyes and inks ($25 million, up 53 percent).

From a geographic standpoint, strong orders from China, South Korea and the United Kingdom offset trade declines with Canada and Mexico for the quarter ended Dec. 31.

Exports to Canada, Minnesota’s largest trading partner, fell 6 percent to $1 billion during the quarter amid weaker orders for machinery, electrical equipment and vehicles.

The state’s second largest trading partner, Mexico was off 11 percent to $566 million.