MADRID — Spain remains in recession but only just.

The country's National Statistics Institute says the Spanish economy contracted in the second quarter by a quarterly rate of 0.1 percent as a result of weak domestic consumer demand. That offset a solid export performance.

That was Spain's eighth straight quarterly fall. The contraction was better than the 0.5 percent fall recorded in the first three months of 2013.

Spain has been in recession for most of the past four years following the collapse of its real estate sector in 2008. Despite 26.3 percent unemployment and a bloated deficit, the government claims its reforms and austerity measures are paying off. It predicts the economy could start growing again in the third quarter.

On a year-on-year basis, Spain's economy was 1.7 percent smaller.