"The attacker entered and began shooting at a couple, and then continued firing in all directions".
The gunman has been identified as 49-year-old Euler Fernando Grandolpho, a resident of the neighboring city of Valinhos, according to state-run news agency Agencia Brasil.
The shooting happened right after the midday service had ended at the Metropolitan Cathedral in Campinas, a city around 100km (60 miles) north of Sao Paulo.
A man opened fire in a cathedral in southern Brazil after Mass on Tuesday, killing four and leaving four others injured before taking a bullet in the ribs in a firefight with police and then shooting himself in the head, authorities said.
Ventura said police officials stationed in the plaza outside rushed into the cathedral after hearing the gunshots.
The wounded were taken to local hospitals; their condition has not been disclosed. The attack also left four worshipers wounded, though not critically. "It´s a big tragedy", the officer said. "It's hard to imagine the pain this has caused".
Five dead in shooting at Catholic cathedral in Brazil: report
The latest incident comes after at least 12 people, including six thieves and a child, died during an attempted robbery of two banks in Milagres city in Ceara state last week.
Grandolpho, a systems analyst, was not a member of the church, authorities said.
"An individual entered a church and opened fire on several people", a police spokesperson said.
Hamilton Caviola Filho, a police investigator said that authorities had reviewed surveillance footage from inside the cathedral.
Brazil past year registered 63,880 murders and its murder rate of 30.8 per 1,00,000 citizens is three times higher than the level the United Nations considers to meet the definition of "endemic violence".
The country´s incoming president, Jair Bolsonaro, who takes office on January 1, easily won November elections on a platform that included promises to ruthlessly crack down on crime and ease gun laws to allow "good" people to defend themselves.More news: Theresa May no confidence Brexit vote: Suffolk and Essex MPs react
More news: Taylor Swift's Reputation Tour to hit Netflix on New Year's Eve
More news: Congress drafts compromise Farm Bill, eliminates SNAP work requirements