The mandate will come into force on Wednesday 10 January, and is due to a spike in cases of flu, Covid-19 and other respiratory illnesses.
The Spanish government decided to impose the measure after failing to reach an agreement with regional health authorities.
Many of the regional governments favoured a recommendation for face masks over making them obligatory in healthcare settings. However, similar measures were already in place in six regions.
Mandatory mask wearing was previously imposed during the Covid-19 pandemic, but was ended in July 2023.