The man, who had reportedly been drinking heavily before the shooting and was armed with a hunting rifle, launched the attack in the village of Daillon late on Wednesday.
As police rushed to the scene to stop the attack, they exchanged fire with the gunman and wounded him, police said. He had been taken to hospital, they said.
"Three victims died at the scene. Two other people were wounded and hospitalized," said police in the canton of Valais, which borders Italy and France.
They did not identify the attacker and his motives were not immediately clear.
At around 8.50pm "the cantonal police headquarters was told that an individual was shooting at residents of the village," police said in a statement on Thursday.
They were told that "several injured people are lying on the ground," adding that police accompanied by special units "immediately intervened and neutralized the suspect," the statement added.
The police came under threat and there was an exchange of fire, resulting in the suspect being wounded, cantonal police spokesman Jean-Marie Bornet told AFP. None of the police were hurt.
The public prosecutor of Valais went to the scene and an inquiry was opened.
He was a resident of the village aged around 30 who had drunk a lot before the shooting, 20Minutes.ch said, quoting a local restaurateur.
Marie-Paule Udry told the site: "He had been in the Channe d'Or earlier in the evening. He had drunk a lot."
In Switzerland, where men are allowed to keep their weapons at home outside periods of military service, the law allows any Swiss citizen aged over 18 to possess arms under certain conditions.
The defence ministry says there are some two million weapons in private hands among Switzerland's eight million inhabitants. But the authorities say there are also some 240,000 unregistered weapons.