Activity in the eurozone's fourth largest economy shrank by 0.1 percent in the April-June period when compared to the previous quarter, the National Statistics Institute said in a report.
The shallow decline, which compared to a 0.4-percent drop in the first quarter of the year, will raise hopes that Spain is set to shake off a stubborn, double-dip recession that pushed the unemployment rate to 26.26 percent in the second quarter.
A property market crash in 2008 plunged Spain into a recession, destroyed millions of jobs, left banks awash in bad loans and plunged the government deep into debt.
The economy emerged only gingerly from that downturn in 2010 before sliding back into recession in mid-2011.
Prime Minister Mariano Rajoy's conservative government and the Bank of Spain now hope the downward cycle may be close to an end, both saying the economy could post growth in the third quarter, propelled by growing exports and a surge in tourism.
On an annual basis the economy contracted by 1.6 percent in the second quarter following a 2.0 percent decline in the first three months of the year.
The European Commission predicts the Spanish economy will shrink by 1.5 percent this year while the International Monetary Fund forecasts a decline of 1.6 percent.
The statistics agency also reported provisional data showing that inflation slowed in August to 1.6 percent from 1.9 percent in July, as increases in fuel and lubricant prices slowed.