The shooting raised questions about relatively liberal gun ownership laws in Switzerland, where citizens are allowed to keep their weapons at home outside periods of mandatory military service.
The 33-year-old man opened fire on the streets of the small village of Daillon near the southwestern city of Sion, said Robert Steiner, police commander in the local canton of Valais.
He used two weapons: a historic Swiss military rifle and a hunting rifle. The man fired around 20 shots, instantly killing three women aged 32, 54 and 79, officials said, and injuring two men, aged 33 and 63, who were taken to hospital.
The gunman was wounded during an exchange of gunfire while being apprehended by police and also taken to a hospital.
Officials said the gunman, whom police did not identify, had spent time in a psychiatric hospital in 2005 and was known to police as a drug user. Police had previously confiscated weapons when he was placed in a psychiatric ward.
His motives for the shooting were not known, but officials said he was a resident of the village and had known his victims.