A 21-year-old college student was shot and killed early Friday on Long Island after an armed man broke into the home she shared with her twin sister, held her hostage and then engaged in a gun battle with the police, the authorities said. The man who forced his way into the home was also killed.

It was not immediately clear who fired the fatal shots, the police said.

The violence played out in the middle of the night on an ordinarily quiet residential street, only blocks from Hofstra University, where the victim went to school. Students who were preparing for their last day of exams awoke to the news that one of their own had been killed, and the normally festive atmosphere that comes with the end of the academic year turned terribly sad.

The victim, Andrea Rebello, was a junior from Tarrytown, N.Y., and was studying public relations. She shared the home with her twin, Jessica, and another young woman, the police said. A young man was also staying at the house at the time.

The suspect, who was not identified, knocked on the door of the home around 2:15 a.m., and when one of the residents looked to see who was there, he burst in, according to the police.