At least ten people were killed at a Brazilian primary school after two teenage boys entered the building and opened fire.

Among the dead were six schoolchildren, one adult who worked at the building, one person who was standing just outside the school and the two adolescent shooters, police said.

At least 17 other people, mostly children, were also shot at the Raul Brasil primary school on Wednesday and taken to hospitals, police said in a written statement.

The state of their health was not immediately known.

The unidentified gunmen, who appeared to be between 20 and 25 years of age, shot and killed a worker at a nearby car wash before their attack at the Raul Brasil school, police said.

More than 1000 children aged between 11 and 15 attend classes there.

Police said the two teenagers wearing face masks entered the building and started shooting at about 9.30am local time (11:30pm AEDT) on Wednesday.

The pair eventually shot and killed themselves.

School shootings are rare in Brazil, even though the country is one of the world’s most violent, with more annual homicides than any other. The last major school shooting was in 2011, when 12 children were shot dead by a former pupil in Rio de Janeiro.

Gun laws are extremely strict in Brazil, but it is not difficult to illegally purchase a weapon.

Marcelo Salles, commander of police forces in Sao Paulo state, spoke just outside the school and said that in his over three decades of service, he had “never seen anything like this, it was an unspeakably brutal crime”.

Mr Salles said the gunmen used at least one .38 calibre pistol, along with homemade bombs and a crossbow.

Police arrived eight minutes after the shooting started and did not confront the gunmen, who had already killed themselves, he said.

A homemade video taken during the shooting and aired by Globo TV showed children screaming, running and begging for their lives as loud shots were heard all around.

Security cameras from homes near the school showed children climbing and jumping over a white wall that surrounds the Raul Brasil building, and sprinting down streets, screaming for help.

Sao Paulo Governor Joao Doria said as he stood outside the school that “our solidarity goes out to the families of the victims”.

“I was shocked with the scenes I saw inside that school,” Doria said. “It is the saddest thing I have seen in my life.”