National weather agency AEMET issued a maximum red alert, which means possible extreme danger, for Sunday in the Madrid region, Toledo province, and the city of Cadiz.
It said up to 120 litres per square metre of rain could fall over 12 hours in Madrid.
“Due to the exceptional and abnormal situation, in which rainfall records will be broken, I ask the people of Madrid to stay at home today,” Madrid Mayor Jose Luis Martinez-Almeida wrote on X, formerly Twitter.
Dark storm clouds were gathering over Madrid during the early afternoon of Sunday, but many people were outside as usual.
“I think (the red alert) is a good idea,” said Madrid resident Manuel Loro, 42. “The best thing to do is not to use your car today. It’s going to be strongest at six o’clock so we’ll go home earlier.”
Madrid’s emergency services sent texts to residents warning them of flood risks and advising them not to use vehicles.
LaLiga suspended an evening match between Atletico Madrid and Sevilla at the Wanda Metropolitano stadium in Madrid due to the alert.
In Alcanar, Tarragona, on Spain’s east coast, emergency services have also confined residents to their homes due to flooding after 215 litres per square metre of rain in the past 24 hours.
(Reporting by Elena Rodriguez, Guillermo Martinez; Writing by Jessica Jones; Editing by Andrew Cawthorne)