The federal government posted a surplus of $1.9 billion for the 2014-2015 fiscal year, according to final numbers from Ottawa released today.

The Department of Finance said the figure is a reversal of a $5.2 billion-deficit posted for the previous fiscal year.

In its recent budget, Ottawa was forecasting a deficit of $2 billion for 2014-2015. The surplus brings an end to a six-year streak of deficits, which began in the fiscal year that ended in April 2009.

The excess financial wiggle room inched Canada's debt-to-gross domestic product ratio down to 31 per cent for the year, from 32.3 per cent the year before.

But that figure doesn't include debts owed by various local, provincial and territorial governments across Canada. Including those figures, Canada's debt-to-GDP ratio rises to 40.4 per cent, which is still the lowest among G7 nations.

According the OECD, the average debt-to-GDP ratio for all G7 countries, when all forms of government debt are included, will be 86.8 per cent for the 2014-2015 fiscal period.

Ottawa's spending increased during the year, coming in at $280.4 billion for the year ended April 1. But that was more than offset by a corresponding increase in revenues, which came in at $282.3 billion, an increase of $10.7 billion or 3.9 per cent.

Program spending was $800 million lower than forecast, while public debt charges were $100 million lower than expected.