1155 GMT October 15, 2019
The shooting happened at about 09:30 local time (1230 GMT) when the students were on a break at the state school in Suzano, near Sao Paulo, according to BBC.
The gunmen, who were wearing masks, killed themselves after the attack, police said.
While gun crime is common in Brazil, shootings of this nature are not.
Far-right President Jair Bolsonaro, who took office in January, has signed a decree making it easier for law-abiding citizens to own a gun, a key campaign promise, even though many restrictions remain in place.
The identities of the victims and the alleged attackers – who were said to be former students at the school aged between 20 and 25 – have not yet been released. The motive for the shooting is not clear, police said.
The school has some 1,000 primary and secondary students, aged between six and 18, and a language center. It is located in downtown Suzano, some 50km (31 miles) from Sao Paulo.
"It's a very sad scene, the saddest thing I've seen in my entire life. The teenagers who were brutally murdered," Sao Paulo state governor, Joao Doria, said after visiting the school.
Only secondary students were reportedly at the school at the time of the shooting. Police said they also found a bow and arrow as well as items that appeared to be explosives.
"I was in the classroom during our break. I thought [the sound] was from bombs. When I realized they were gunshots, I stayed there. I only left when the police arrived," teacher Sandra Perez told O Estado de Sao Paulo newspaper (in Portuguese).
A man was injured in another shooting near the school earlier, but police said they are still investigating if both cases are connected.
The last major school shooting in Brazil happened in 2011, when 12 students were shot dead by a gunman in Rio de Janeiro.