In the first six months of 2013, the state deficit — the spending overshoot by central government institutions — fell to 3.81 percent of output from 4.15 percent in the same period last year, it said in Tuesday's statement.
Fighting to stabilize its public finances, the government has agreed to reduce the overall public deficit in the eurozone's fourth-biggest economy to 6.5 percent this year, including 3.8 percent for the central state deficit.
This state deficit was €40 billion ($53 billion) in the first half of 2013, the ministry said.
A large share of that was due to higher interest rates on Spain's public debt, which was equivalent to 88 percent of output in the first quarter, the ministry said.
The overall public deficit also includes the budgets of local authorities and welfare programmes.
The data added to recent positive signs for Spain's economy, in recession since late 2011. The government and central bank are forecasting a return to growth in the third quarter.
Wednesday's state deficit figures showed that "the Spanish economy is at a turning point," Budget Minister Cristobal Montoro said in the statement.
"From now on we are on a different path to restoring economic activity, strengthening our economic growth and coming sooner rather than later to job creation."
Official data on Tuesday showed the recession eased in the second quarter.
Output shrank by 0.1 percent in the three months ending June as booming exports helped to offset weak domestic demand, compared to a 0.5 percent contraction in the first quarter.
Analysts at finance group BBVA Research said Spain would be on track to meet its deficit targets if the trend indicated by Wednesday's figures continued, but warned of continued risks such as rising interest on its debt.