It happened in the southeastern city of Campinas, about 100 kilometres from Sao Paulo. Reports say the man then shot himself dead.
Several other people were said to have been injured in the rampage.
Three were taken to hospital while four people were unharmed in the attack.
Media reports have identified the gunman as a man in his forties who was angry over a split with his wife.
One neighbour said he and his family thought the gunshots were fireworks until a wounded person ran out of the house pleading for help.
Although gun crime is high in Brazil, targeted mass killings are rare.