The man was carrying "several firearms" when he broke into the house in Campinas in southeastern Brazil, AP reports. Military police Corporal Marta Aurelia confirmed that the man's eight-year-old son was among the 13 dead in the attack, but could not say whether the number of dead included the gunman.
Many of those killed were relatives of the man's ex-wife and son.
Some of the wounded fled to a neighbor's house, BBC reports.
"When we opened the gate to go into the street to see the fireworks, the celebrations, a wounded person came into our yard. He entered, asking for help,'' neighbor Christiano Machado said. They had assumed the gunshots were fireworks.
In 2015, the government of Brazil took steps to address the gender-based violence that plagues the country, ratcheting up penalties for murders of women or girls in which gender is found to have played a role.
Brazil has made headlines this year for its violence. More people died violent deaths in the Latin American country than were killed in Syria, one notable comparison showed.