Eurozone finance ministers have agreed to lend Spain 30bn euros (£24bn; $37bn) this month to help its troubled banks.
It will be the first instalment of a bailout of up to 100bn euros, which was agreed in June.
The ministers will need to get approval from their own parliaments and hope to make the payment by the end of July.
The eurozone finance ministers also agreed to extend the 2013 deadline for Spain to cut its budget deficit to the EU limit of 3% by one year.
The yield on Spanish bonds rose sharply on Monday ahead of the meeting, with many fearing that little concrete action on Spanish banks would be reached.
"We are aiming at reaching a formal agreement in the second half of July, taking into account national parliamentary procedures, allowing for a first disbursement of 30bn euros by the end of the month to be mobilised as a contingency in case of urgent needs in the Spanish banking sector," Eurogroup President Jean-Claude Juncker said.
"There will be specific conditions for specific banks, and the supervision of the financial sector overall will be strengthened," he added.
The exact amount that Spain needs for the bailout of its banks may not be known until September.
The conclusions of the finance ministers from the 17 countries that use the euro will be submitted to a meeting of all 27 EU finance ministers later on Tuesday.
Mr Juncker also said that Madrid should implement measures needed to bring its public finances into line with EU norms.
On Saturday, Spanish Prime Minister Mariano Rajoy announced that he would take further steps soon to cut the country's public deficit.
In a news conference at the end of Monday's marathon meeting, a number of appointments were also announced.
The ministers reappointed Mr Juncker as their chairman and picked German Klaus Regling to head the permanent bailout fund, the European Stability Mechanism (ESM), which is due to come into force this month.
It was meant to begin operations on Monday, but has not yet been ratified by the required number of member states.
The finance ministers meeting in Brussels also agreed that, once the single European banking supervisor has been set up next year, banks may be helped directly by the ESM without the need for state guarantees.
This was seen as a key part of attempts to stop the aid being given to weak banks from adding to countries' debts.
But there had been some objections to the measure from northern European countries.
Meanwhile, Germany's constitutional court will be sitting in Karlsruhe to hear objections to the ESM on Tuesday.