A 21-year-old Hofstra University student who was killed in a home invasion on Friday was mistakenly shot in the head by an officer who fired eight times at a man who was holding a gun to the student’s head and then pointed it at him, the police said on Saturday. Seven of the bullets hit the man, who was also killed.

The student, Andrea Rebello, and her twin sister, Jessica, who also lived at the home, just blocks from the university, were among several people taken hostage on Friday morning in an apparent robbery attempt.

The Nassau County police identified the gunman as Dalton Smith, 30, a Hempstead, N.Y., resident with an extensive criminal record who was wanted for violating parole on a robbery conviction.

About 15 or 20 minutes elapsed from the time Mr. Smith burst into the home about 2:20 a.m. Friday until the last shot was fired, the police said.