Madrid has for months appealed for more EU aid to help it contain a surge in the arrival of sub-Saharan African migrants at the two cities, which are both on Morocco's Mediterranean coastline and have Europe's only two land borders with Africa.
EU Home Affairs Commissioner Cecilia Malmstrom said the bloc would "immediately" provide Madrid with 10 million euros during talks in Madrid with Spanish Interior Minister Jorge Fernandez Diaz, the interior ministry said in a statement.
The money will come from the EU's emergency fund and it will be used on "some of the 26 projects proposed by Spain to face the situation in Ceuta and Melilla", the statement added.
Part of the funds will be used to strengthen border fences, fund voluntary return programmes for migrants who manage to enter the two territories illegally and make improvements to government-run migrant reception centres.
Last week about 500 African migrants leapt a towering, triple-layer border fence to cross from Morocco into Melilla.
A reception centre in Melilla is built to house 480 immigrants but now houses over 2,000 people.
Aside from trying to storm the border fence around Melilla, would-be immigrants also try to sail or swim to Melilla and Ceuta which sit on the Mediterranean opposite mainland Spain.
On February 6th about 15 migrants drowned in Moroccan waters while trying to swim to Ceuta from a nearby beach.
Spain's interior minister on March 4 estimated there were 40,000 migrants waiting to cross from Morocco into Ceuta and Melilla.
Another 40,000 were waiting to enter Morocco from Mauritania en route to the two cities, he added.