About 40 migrants fought police at the centre in the Mediterranean port of Valencia late on Sunday and dozens tried to escape, a police spokesperson said.
"They jostled police, hit them, ripped the keys from one of them and removed the belt from another. Five police officers were lightly injured," he said.
About 20 migrants, all of them men, used the keys to reach the roof of the centre and tried to escape using sheets and blankets and threw rocks at police who tried to stop them.
Migrants inside the centre smashed furniture and tried to set fire to mattresses, prompting firefighters to intervene. Migrants also threw rocks at the firefighters.
Police fired blanks and managed to bring the situation under control at around 1 am, about two hours after the riot started, the spokesperson said.
The centre, dubbed an Internment Centre for Foreigners or CIE by its Spanish acronym, is one of several used to hold undocumented immigrants while their case is analysed or until they can be deported.
The spokesperson could not say how many migrants were at the centre at the time of the riot, saying only that it had an occupancy rate of 42 per cent.
Non-governmental organisation "CIEs NO", which lobbies against holding undocumented migrants in detention centres, said the centre has 150 places.
In June the centre blasted living conditions at the centre, especially the lack of toilets inside cells.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ