A man opened fire in a cathedral in southern Brazil after mass, killing four and leaving four others injured before turning a gun on himself, authorities said.

The shooting occurred right after mass at the Metropolitan Cathedral in Campinas, a city about 60 miles north of Sao Paulo, according to Wilson Cassante, a spokesman for the archdiocese.

He said the officiating priest had left before the shooting began.

A spokesman for Sao Paulo state firefighters said four injured people had been taken to local hospitals.

Their conditions were not immediately known.

Brazil Cathedral Shooting
People gather outside the Metropolitan Cathedral after a fatal shooting (VIctor R. Caivano/AP)

Mr Cassante said church officials did not recognise the gunman or have any ideas about his motive.

“It’s so sad,” said Mr Cassante.

“It’s hard to imagine the pain this has caused.”

Hamilton Caviola Filho, a police investigator, told news portal G1 that authorities had reviewed surveillance footage from inside the cathedral.

Brazil Cathedral Shooting
Two people shot by a gunman lie wounded at the entrance of the Metropolitan Cathedral (Campinas City Hall/AP)

The gunman “came into the church, sat on a chair, with time to think, and then got up and starting shooting”, said Mr Caviola Filho.

The investigator also said that before shooting himself in the head, the suspect took a bullet in the ribs from responding police.

In total, the suspect fired at least 20 shots, said Mr Caviola Filho.

Brazil Cathedral Shooting
The Metropolitan Cathedral after the shooting (VIctor R. Caivano/AP)

Images on Globo News showed paramedics taking bodies and injured from the church.

Firefighter Alexandre Monteiro told G1 that the four injured were in stable condition.

The motive was not clear.

Authorities have yet to release the name or age of the suspect.

While Brazil leads the world in total annual homicides, mass shootings are relatively rare.