Among the dead were five school children, one adult who worked at the building, one person who was standing just outside the school and the two adolescent shooters, police said.
Police said in a written statement that no fewer than 17 other people, mostly children, were also shot at the Raul Brasil elementary school and taken to hospitals.
However, the state of their health was not immediately known.
School shootings are rare in Brazil, even though the country is one of the worlds 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.
While gun laws are extremely strict in Brazil, it is not difficult to illegally purchase a weapon.
Police said that two adolescents wearing face masks entered the building and started shooting at about 9:30 a.m. local time.
The pair eventually shot and killed themselves.
Another shooting took place about 500 metres from the Raul Brasil school shortly before the killings at the school, however it was not yet clear if the two incidents were related.
About 1,000 children attend the school, police said.