Police said that two adolescents, wearing face masks, entered the building and started shooting at about 9:30 am local time (06:30 GMT). Investigators said they had a pact to die together in the attack although Globo TV, citing police, reported that Monteiro killed Castro, and then turned the pistol on himself.
While gun crime is common in Brazil, shootings of this nature are not.
Far-right President Jair Bolsonaro passed a law allowing people to carry arms soon after assuming power in January, delivering on a campaign promise. Students at the school range in age from 11 to 18. He said authorities do not believe the two were former students.
Students outside the school recounted harrowing attacks and seeing several bodies.
Brazil has one of the world's highest murder rates, but school shootings are rare.
Gun laws are strict in Brazil, but it is not hard to purchase a weapon illegally.
Police officers guard the entrance of the school
Neighbors who heard commotion coming from the school looked outside their windows and doors to see terrified students jumping over a fence that surrounded the building and running down the street.
"We can't let those who take advantage of this tragedy speak about how disarmament is the solution", he tweeted, adding: "Weak and shameful 'disarmament farce, ' which gave guns to criminals and prevented self-defense".
A man was injured in another shooting near the school earlier, but police said they were still investigating if both cases were connected.
Police work at the scene on Wednesday.
Sao Pulo governor, Joao Doria, decreed a three-day official mourning, with flags at half-mast, for the 10 deaths occurred this Wednesday after a school shooting in the state. "It is the saddest thing I have seen in my life".More news: Hearn optimistic over Joshua-Wilder deal
More news: Connecticut Supreme Court: Suit Against AR-15 Manufacturer Can Proceed
More news: Michael Bennett rolls out Patriots-Star Wars comparisons on Twitter