A higher tax take has put the Government's books in the black.
Excluding investment gains and losses, the operating surplus stood at $9 million for the six months to December, compared with the $666 million deficit that had been forecast in the Half Year Economic and Fiscal Update.
The growing economy boosted tax revenue, which came in above expectations at $35.4 billion.
The improvement was led by a stronger than expected GST take, with the rising population and record numbers of tourists spending more at the shops, eating out and on accommodation.
Expenses came in below expectations, down 0.8 percent to $38 billion.
Treasury says that was due to uncertainty over the costs of the Kaikōura earthquakes, which have yet to be included in the actual results.
Kaikōura repairs have been estimated to cost $2 to $3 billion.
The government added $1 billion in quake-related expenses to its forecasts, with $685 million of that due to EQC claims costs, and the remaining $315 million attributable to other things, such as funding local infrastructure.
A surplus of $473 million was expected in the June 2017 financial year.