A gunman opened fire inside a cathedral and fatally shot four people praying in the pews. The shooter, Euler Fernando Gandolfo, 49, then turned the gun on himself in front of the altar before police could arrest him.
The attack happened towards the end of a midday service in the Metropolitan Cathedral in Campinas city, police said.
Video footage showed Gandolfo walk into the cathedral and sit down before he started shooting at people.
Worshippers could be seen desperately trying to flee the Catholic cathedral after he started firing at them.
Police in the plaza rushed in when they heard the shots but he killed himself before cops could arrest him.
Hamilton Caviola Filho, a police investigator, said Gandolfo was shot in the ribs by police before turning the gun on himself.
Gandolfo, a systems analyst from Valinhos with no criminal record, had two guns with 28 rounds left when he died.
The motive for the attack is not yet clear.
Pedro Rodrigues, 66, said: “I suddenly saw a man stand up, take position in front of a couple and shoot them point blank. I ran out fast and he continued firing, many shots.”
“It was frightful,” Alexandre Moraes told GloboNews channel. “He shot randomly at people. They were all praying.”
Brazil had nearly 64,000 murders last year – more than any other country, according to the United Nations.