Twelve men and 10 women aged between 45 and 94 have contracted the disease since September 5 in the town of Sabadell, near Barcelona, the Catalonia regional health department said in a statement.
"Two of the patients, both of whom had risk factors and major previous pathologies, have died," it said late Tuesday, without further identifying the patients.
Of the others, 17 remained in hospital and three had been discharged, it said.
Legionnaire's disease is a lung infection caused by the legionella bacteria. It is not contagious but can multiply in water and air conditioning systems.
The health department said it had not detected the source of the outbreak but suspected it was close to places in Sabadell frequented by the patients.