Three men were killed and two others were injured after dozens of shots were fired by a homeowner in Texas during a home invasion early Sunday, officials said.

The incident happened around 1 a.m. in east Houston after five men wearing ski masks broke into the home, police told KPRC.

The male resident inside then grabbed his weapon and opened fire at the men.

"The homeowner appears to have defended himself," Houston Police Department homicide detective Travis Miller told KTRK-TV.

OREGON GIRL, 8, THANKS 'ANGEL' FOR STRENGTH, POLICE FOR SAVING HER FROM MAN WITH AX WHO KILLED 4 IN HOME

A shootout then took place between the groups, according to police.

"We have multiple, multiple shell casings from several different types of guns," Miller said.

A neighbor told KTRK he heard the shots and went outside to make sure he wasn't dreaming.

"I heard around five or six gunshots," he told the television station. "I'm pretty sure there were more before that."

SAN FRANCISCO POLICE ARREST SUSPECT IN BRUTAL BEATING OF 88-YEAR-OLD GRANDMOTHER

One of the suspects was found dead in front of the house, while the others fled in an SUV and on foot. Police told KPRC that the SUV crashed into a pole nearby and a second suspect was found dead inside.

CLICK HERE FOR THE FOX NEWS APP

A third suspect who was in the SUV fled, collapsed in the street, and later died, KPRC reported.

The fourth and fifth suspects, who were also injured in the shooting, were taken to the hospital. The incident remains under investigation by police, who did not release additional information. The homeowner was not injured.