Three women were killed and two men were wounded late on Wednesday when a gunman opened fire in the Swiss village of Daillon, Swiss police and prosecutors said on Thursday.
The 33-year-old gunman, who has not been named, threatened police when they tried to arrest him and was shot in the chest before being arrested and taken to hospital, police in the Swiss canton of Valais said. No police officers were wounded.
Gun ownership is widespread in Switzerland and voters rejected a proposal in February 2011 to tighten the country's liberal fire arms laws.
The women killed in Daillon were aged 32, 54 and 79. They were all shot at least twice, in the head and chest. The youngest was married to one of the injured men and they had young children together, regional public prosecutor Catherine Seppey told a news conference.
The injured men were aged 33 and 63.
The gunman was a local resident who had been in psychiatric care in 2005 and was unemployed and living on welfare benefits, police said. His only previous conviction was for marijuana use.
He used at least two firearms - an old Swiss army carbine and a rifle capable of firing lead shot - even though his weapons had been seized and destroyed in 2005, and he was not currently listed as having any guns.
He began firing from his apartment, shooting at people in the street and in neighbouring buildings, but later came out into the street, police said, adding that he appeared to have fired more than 20 shots.
Swiss website 20minutes.ch quoted villagers as saying the gunman had been drinking heavily. It also said he was armed with an assault rifle, but the public prosecutor did not confirm that information.
The village is close to the town of Sion, the capital of the canton - or region - of Valais.
A shooting in the regional parliament in the canton of Zug in 2001 stirred debate over gun control in Switzerland, where - according to some estimates - at least one in every three of its 8 million inhabitants holds a gun.
Many are stored in people's attics, a legacy of Switzerland's policy of creating a citizen army that can be mobilised quickly to defend its neutrality.