This is a huge cut in the midst of a recession but still short of the country's European Union target.
Rajoy's conservative government rammed through unpopular austerity cuts and tax increases as it struggled to lower the public deficit to an EU-agreed target of 6.3 percent of gross domestic product in 2012 from 9.4 percent back in 2011.
Spain's budget-cutting achievement will likely be welcomed by financial markets despite missing the goal set with Brussels.
But the cost-cutting, coming at a time when Spain is in deep recession with a jobless rate of 26 percent, has sparked regular, mass street protests including two general strikes in the year since Rajoy's Popular Party came into power.
"It represents a huge effort by the whole of Spanish society," the prime minister said in parliament.
"It will no doubt lead to a boost in confidence in Spain."
The deficit figure does, however, exclude the cost of rescuing Spain's banking system from a mountain of bad loans built up since a 2008 property crash.
Spain has already shelled out more than €40 billion ($52 billion) to clean up its banks' balance sheets, using a rescue loan extended by its eurozone partners of up to €100 billion , and it will have to pay that money back.
The European Union last week estimated the overall Spanish public deficit at ten percent of GDP, saying the cost of the banking rescue accounted for 3.2 percentage points of the total.
Since coming to power in December 2011, Rajoy's Popular Party government has launched measures to find €150 billion in savings from 2012 to 2014 in spending cuts and tax increases.
For next year alone, the government's budget foresees €39 billion in austerity measures.
"The 2013 budget foresees the end of recession," Rajoy declared.
His government forecasts an economic contraction of 0.5 percent next year, significantly more optimistic than most international predictions centred on a downturn closer to 1.5 percent.