Six students and two teachers were killed in the attack at the public school in Suzano, a suburb of Sao Paulo, according to the Associated Press. Officials said several people were receiving treatment for injuries.
The attackers appeared to be in their early to mid-20s and were not former students, AP reported.
The school was evacuated and security forces were investigating the possibility that explosives had been left at the building by the attackers.
Pupils gathered outside the school and recounted details of the attack, describing bodies lying in pools of blood.
A 15-year-old student told the G1 news site that they heard three shots and then tried to flee. The student said the shooters had guns and knives.
An eyewitness who lives next to the school said the gunshots started around 10:00am local time and then young people began to flee the school grounds.
More than 1,600 students attend the Raul Brasil Professor public school, which caters for primary school grades to high school.
School shootings are rare in Latin America despite the continent’s large number of annual murders.
President Jair Bolsonaro campaigned on the basis that he would crack down on criminals through expanding public access to guns.