Spain saw close to a 40 percent rise in capital outflow in June, Bank of Spain data showed on Friday, as investor confidence in a country struggling to balance its public accounts eroded further.

According to Reuters, the central bank reported that net capital outflow, not including central bank operations, was 56.6 billion euros ($71 billion) in June, after an outflow of 41.3 billion euros in May.

A total of 315.6 billion euros of capital has left the country year-to-date through June 30, equivalent to nearly one-third of the country's economic output. 

Spain's economy entered a recession at the end of last year, and falling output and tax revenues will test the country's ability to cut its public deficit to meet European Union demands.

One analyst said Spain's dire situation would be helped if the country called for a rescue package to lower its financing costs, something the government is contemplating.

"The capital outflow is due to a lack of confidence from foreign investors in the country's solvency, and I hope this changes when the ECB (European Central Bank) starts buying debt," said Nicolas Lopez, economist at M&G Valores.