SÃO PAULO, Brazil — A man opened fire in a cathedral in southern Brazil at the end of Mass on Tuesday afternoon, killing four people and injuring four before he fatally shot himself, according to the authorities and witnesses.

The shooting took place at the Metropolitan Cathedral in Campinas, a Roman Catholic church in a wealthy agricultural city about 60 miles northwest of São Paulo. Footage from a security video shows the shooter, seated in a pew, suddenly stand up and take aim at parishioners right behind him. He then fires on people as they try to flee the church.

The authorities did not release the name of the shooter but said he was a man with no police record who worked as a computer technician, according to a spokesman for the Campinas Firefighters Department who asked not to be named. The assailant was armed with two handguns and his motive is not known, the spokesman said.