A firebug sparked an inferno at a Queens home on Wednesday, killing himself and two others — including a 6-year-old girl, sources said.

David Abreu Nuñez, 23, went berserk inside the two-story residence in East Elmhurst at about 4 p.m. — tossing gasoline around the kitchen before torching the home, according to police sources.

“Unfortunately, it’s a sad afternoon here in East Elmhurst,” FDNY Commissioner Daniel ­Nigro said at the scene.

“Two of the occupants had evacuated. They were very critically injured. Three people were still inside.”

The little girl was declared dead at the scene along with Nuñez, the sources said, adding that the child’s 76-year-old great-grandfather was taken to NewYork-Presbyterian Queens hospital, where he died.

Also injured were a 35-year-old woman and her 10-month-old son.

Sources said they suffered burns over 70 percent of their bodies and were taken to Manhattan’s Weill Cornell Burn Center, where they were in critical condition.

“The fire happened really fast,” a neighbor said.

Another neighbor told The Post a woman came “running out with her baby screaming, ‘There’s a fire!’ ”

The names of the deceased, other than Nuñez, were not released Wednesday night.

Authorities were trying to contact family members outside the United States.

Nuñez had been staying at the home with the family and had an as-yet-undetermined connection with them, officials said.

Sources said some of the relatives had been visiting from the Dominican Republic.

“It’s quite unusual at that time in the afternoon to have a fire trap five occupants in a private dwelling,” Nigro said.

“The first call we received at 4:09 came from the occupant of the first floor of that apartment, who heard an alarm going off and called 911.”

A woman who declined to comment broke down in tears in front of the residence on Wednesday evening.

Police were still trying to determine what caused Nuñez to suddenly set the home on fire.

Additional reporting by Tina Moore and Ben Cohn