Spain said Monday it is open to negotiating a new bailout for Greece, which should remain in the eurozone, after Greek voters rejected creditors' austerity demands in a weekend referendum.
Athens "has the right to ask for a third rescue package. The Spanish government is open to these negotiations," Economy Minister Luis de Guindos told a news conference.
"Given the circumstances, from the point of view of the markets it is absolutely necessary," he added.
Spain is "absolutely not contemplating a Greek exit from the euro", the minister said in the first reaction from Spain's conservative government to the outcome of the Greek referendum.
Despite warnings from European leaders that Sunday's referendum was effectively an in-out poll on the euro, more than 60 percent of the Greek voters heeded their government's call to vote "No".
Greek Prime Minister Alexis Tsipras had argued during the campaign that a "No" vote against accepting debt reform proposals from Greece's creditors -- the so-called 'troika' of the European Central Bank, the European Commission and the International Monetary Fund -- would strengthen his hand in future negotiations.
De Guindos recognised that Greece's creditors had made "mistakes" in their handling of the crisis.
"The troika, not just in Greece but also in other nations, has not always shown great sensibility from an economic and social point of view.
"I think that there were mistakes on the part of the troika, but it is inevitable that Greece make reforms because there have been nations that have done them and they are emerging from the crisis," he added.
The Spanish government has imposed unpopular government spending cuts to bring its public deficit to within European Union limits and has taken a hard line regarding Greece.
Spain, the eurozone's fourth-largest economy, was battered by the global financial crisis and only emerged from a double-dip recession at the end of 2013.
"If Greece had applied its (reform) programme, it would not have needed a restructuring of its debt," the economy minister said.
"It is the deterioration in these recent months that have led to the perception the (debt) ratio is not sustainable," he added.
Greece's debt amounts to 180 percent of its economic output, he said.
De Guindos shrugged off the prospect that Greece's troubles could harm Spain's economy.
"The position of the Spanish economy is completely different," he said.
Spain's economy has grown for the past seven quarters although the jobless rate remains high at 23.8 percent, the highest in the European Union after that of Greece.
Last week the government raised its growth forecast for 2015 to 3.3 percent from a previous forecast of 2.9 percent.
The Spanish economy grew by 1.4 percent in 2014, its first full year of growth since a property bubble burst in 2008, throwing millions of people out of work.