Spain posted a strong budget surplus in 2007, the second-largest in the eurozone, according to official data.
Spain has posted the second largest surplus in the eurozone
Spain's surplus rose by a third year-on-year to 23.4bn euros (£17.6bn), hitting 2.2% of gross domestic product.
It is the third year in a row that Spain has achieved a surplus - by limiting public spending - after 30 years of deficits.
But separately, the European Commission lowered its eurozone growth forecast for 2008, including Spain.
On Thursday, the commission cut its forecast for the region as a whole to 1.8% from its November estimate of 2.2%, adding that inflation would stay high.
It predicted that Spain's economy would expand by 2.7%, rather than the 3% forecast earlier.
Spain, which is to have its election on 9 March, has been facing a slowing economy.
Prime Minister Jose Luis Rodriguez Zapatero has said in order to maintain growth at around 3%, he would be prepared to use the surplus to finance tax cuts and counter any wider global economic slowdown.