GREAT MILLS, Md. -- A teenager with a handgun opened fire inside his Maryland high school Tuesday before he was fatally wounded during a confrontation with a school resource officer, a sheriff said. Deputies and federal agents converged on the crime scene at Great Mills High School, about 65 miles southeast of Washington.

It wasn't immediately clear whether the shooter took his own life or was killed by the officer's bullet, St. Mary's County Sheriff Tim Cameron said.

A 16-year-old girl, later identified as Jaelynn Willey, was hospitalized with a life-threatening wound, the sheriff said, and a 14-year-old boy also suffered a gunshot wound to the thigh. He was in good condition. The officer, who doubles as a SWAT team member, was unharmed.

Get Breaking News Delivered to Your Inbox

Cameron identified the suspect as 17-year-old student Austin Wyatt Rollins. He said Rollins used a Glock semiautomatic handgun to shoot the girl, who he had a prior relationship with.

Deputy First Class Blaine Gaskill, school resource officer at Great Mills High School in Maryland St. Mary's County Sheriff's Office

A school resource officer, Deputy First Class Blaine Gaskill, then faced off with the shooter, the sheriff said. Each fired one shot simultaneously. Cameron said the gunman later died from his wounds. He said that the investigation would determine whether the round the officer fired hit the shooter.

Cameron said he didn't know the nature or extent of the relationship between the suspect and the girl. Investigators are working to determine whether that was part of the motive.

"This is something that we train, practice, and in reality we hope would never come to fruition, it is our worst nightmare," Cameron said at a press conference Tuesday.

Responding to a question from CBS News' Jeff Pegues, Maryland Gov. Larry Hogan said it's possible the actions of the school resource officer may have saved others' lives.

"It sure sounds like this is exactly the way it should have been handled," Hogan said.

St. Mary's schools superintendent James Smith also praised the actions of the school resource officer, as well as first responders and school staff. He said the county has re-engaged in a conversation about school safety after the school shooting that left 17 dead last month in Parkland, Florida.

"If you don't think this can't happen at your school, you are sadly mistaken," Smith said.

Officers in St. Mary's have undergone additional training to prepare individual officers to confront shooters, according to Cameron. He said that while he couldn't speak to the shooter's motive or target, "What we do know is the [school resource officer] did his job, engaged, and stopped the potential threat."

Politicians responded swiftly, acknowledging that this shooting increases the pressure for action against gun violence as anger swells nationwide over the Parkland killings by a teenager with an assault weapon.

However in this case, it appeared that the shooter had illegally possessed the gun. In Maryland, a person must be 21 to possess a handgun, unless carrying one is required for employment.

St. Mary Co. Sheriff Tim Cameron on shooting at Great Mills HS: shooting happened in hallway; shooter, a student, fired at a female student, another was student hit. Armed school resource ofc, a deputy, exchanged shots w/ shooter; shooter & female student in critical condition — Peggy Fox (@PeggyTV) March 20, 2018

Student Mollie Davis told CBS News over Twitter that she heard what sounded like a loud balloon pop.

"I was in my classroom and heard everyone screaming," Mollie said. "I've never heard people sound so scared."

Police officers told students that the threat was over and the school would be evacuated soon, the student said.

The Baltimore Sun reported that a student said the shooting happened around 8 a.m. Terrence Rhames, 18, told the Sun that he heard a gunshot and saw a girl fall as he ran for an exit. "I just thank god I'm safe," Rhames said. "I just want to know who did it and who got injured."

Agents with the FBI and the Bureau of Alcohol, Tobacco, Firearms and Explosives joined deputies at Great Mills High School as students endured a lengthy lockdown, cowering inside classrooms and a locker room while officers worked to make sure there were no more threats on campus.

Police eventually kicked in the locker room door, said Ziyanna Williams, a 14-year-old ninth-grader.

"They came in with guns, and they probably thought there might be another shooter, of course," she said. "About an hour or two later they came -- more police came -- and told us they would search us and search our bags and stuff."

Eventually, the students were escorted outside.

The school has about 1,600 students and is near the Patuxent River Naval Air Station. On Tuesday, ambulances, firetrucks and other emergency vehicles crowded the parking lot and the street outside, where about 20 school buses lined up in the rain to take students to nearby Leonardtown High School to be picked up by their parents.

Democratic Rep. Steny Hoyer said the officer at the school "answered the call this morning with swiftness, professionalism, and courage." He said it's now for Congress to take action.

"We sympathize. We empathize. We have moments of silence. But we don't have action," Hoyer said. "Wringing our hands is not enough."