The deficit shrank to 297 billion riyals ($79 billion) in 2016. That was well below a record 367 billion gap in 2015, and below the government's projection in its original 2016 budget plan of a deficit of 326 billion riyals.
"Our economy, thank God, is sturdy and it has enough strength to cope with the current economic and financial challenges," King Salman said in a nationally televised address to introduce the budget for 2017.
The financial challenges for Saudi Arabia stem largely from the fall in the global price of oil over the past 2½ years.
It is not yet been announced how the 2016 deficit stacks up as a percentage of the economy. It was 15 percent of GDP in 2015.
The drop in the deficit is nonetheless likely to reassure international investors worried about Saudi Arabia's ability to cope with an era of cheap oil. The riyal came under speculative pressure this year but currency jitters have eased in recent months.
Riyadh slashed spending on infrastructure and perks for civil servants to get its finances under control. For the first time in years, it kept its spending below its original budget projection in 2016; actual spending was 825 billion riyals compared with a projection of 840 billion riyals.
Revenues came in slightly higher than expected at 528 billion riyals instead of 514 billion riyals as the government raised cash with steps such as higher municipal and visa fees.
In its 2017 budget plan, Riyadh said it would increase spending to 890 billion riyals from the 840 billion riyals originally projected for 2016. But next year's deficit will shrink further to 198 billion riyals because of higher oil prices and non-oil revenues, the government said.
Economic growth slowed to 1.4 percent in 2016, far below the average of 4 percent in the past decade, as austerity measures hurt consumers' income and deterred private companies from investing — even though their investment is vital to diversify the Saudi economy beyond oil in the long term.
By increasing state spending on infrastructure, the 2017 budget aims to support economic growth, while a new system of cash payments to poorer citizens will offset the impact on them as the government gradually raises domestic energy prices to reduce its subsidy burden, the finance ministry said.
It gave no details of the planned subsidy cuts.