(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.

"He responded exactly as we train our personnel to respond," he said.

The incident is the 17th school shooting in the United States since January 1, according to CNN research.

"This is what we train for, this is what we prepare for, and this is what we pray that we never have to do. On this day, we realized our worst nightmare," Cameron said.

"The notion of 'it can't happen here' is no longer a notion."

The school was on lockdown for a brief time, and students were evacuated from Great Mills High School to a reunification center at a nearby high school, the school system said.

'I'm still a little shaken up'

School buses lined up in front of Great Mills High School after a shooting on Tuesday to transport students to another school.

Toni Foreman, who lives near the suspect and his family in nearby Lexington Park, said he was a good kid from a nice family who used to play catch and ride bikes with her son.

"Whenever snow was out, he would help shovel," she said. "I'm just totally floored that it was him."

Jonathan Freese, a student at Great Mills, called CNN from his cellphone during the lockdown in his math class. Police were going through classrooms to clear the school, Freese said.

"I'm still a little shaken up," he said.

A mother walks with her daughter, a student from Great Mills High School, as she picks her up from a nearby high school in Leonardtown, Maryland, on Tuesday.

Freese said the school had held drills a couple of times for this kind of situation.

"I didn't really expect for this to happen. I do always feel safe, though, because they always have police at the school," he said.

Great Mills High School is in Great Mills, about 70 miles southeast of Washington. It has more than 1,500 students, about 56% of them minority students, and its four-year graduation rate is 91%, according to the school's 2015-16 improvement plan.

17th school shooting this year

Last week, students at Great Mills High School walked out of class as part of a student-led protest against school violence in the wake of the mass shooting at Marjory Stoneman Douglas High School in Parkland, Florida.

Several students from Stoneman Douglas tweeted about the Great Mills school shooting on Tuesday, offering their thoughts and calling for an end to gun violence in schools.

"The words School & Shooting should not be next to each other. Headlines like this should not have to be typed up every week. All of these incidents have one thing in common. My thoughts are with Maryland right now," tweeted student activist Adam Alhanti.

Other Stoneman Douglas students contrasted the Maryland school resource officer's quick response with the Stoneman Douglas officer's decision not to enter the school and engage the shooter.

"At least someone is doing their job," Stoneman Douglas student Tanzil Philip said. "I feel like if our (school resource officer) would have went in the building, the overall result would've been less bad."

"It makes me feel angry that the protocols were not effective in our situation," said Demitri Hoth, another Stoneman Douglas student.

Gov. Larry Hogan said the shooting was a "call to action" to address school safety.

"Although our pain remains fresh and the facts remain uncertain, today's horrible events should not be an excuse to pause our conversation about school safety. Instead, it must serve as a call to action," he said in a statement.

Speaking to reporters, President Donald Trump called the shooting "a terrible thing."