Canada posted a preliminary budgetary deficit of $21.85 billion for the 2016-17 fiscal year, largely in line with what the government had projected, the Finance Department said on Friday.

The deficit for the fiscal year that ended in March was significantly wider than the $1.96 billion deficit the government ran in the previous fiscal year as program expenses jumped, partly due to a revamped children's benefit.

While the deficit for 2016-17 was slightly smaller than the $23.0 billion gap the government projected in its most recent budget, final results for the year will reflect end of year adjustments that are made as data becomes available, the Finance Department said.

Taking those adjustments into account, the figures are "broadly in line" with the government's forecast, the department said.

The ruling Liberals ran a successful 2015 election campaign on a pledge to run deficits in order to boost spending and stimulate the economy.

For the month of March, the government ran a deficit of $10.39 billion, wider than the $9.44 billion it posted the year before as program expenses exceeded revenue.