(CNN) A 17-year-old male student shot two other students at Great Mills High School in Maryland on Tuesday morning before a school resource officer engaged him and stopped the threat, authorities said.

The incident began in a school hallway at 7:55 a.m., just before classes started. Authorities say Austin Wyatt Rollins, armed with a handgun, shot a female and a male student. The shooter had a prior relationship with the female student, St. Mary's County Sheriff Tim Cameron said.

School resource officer Blaine Gaskill responded to the scene in less than a minute, the sheriff said. Gaskill fired a round at the shooter, and the shooter fired a round simultaneously, Cameron said.

Rollins was later pronounced dead. Gaskill was unharmed. The 16-year-old female student is in critical condition with life-threatening injuries, and the 14-year-old male student who was shot is in stable condition.

Cameron said he was not sure whether Gaskill's bullet hit the suspect, but he praised the officer's quick response to the situation.

Read More