By Matthew Barakat and Jesse J. Holland

Associated Press

GREAT MILLS, Md. — A teenager with a handgun shot and critically wounded a girl inside a Maryland school on Tuesday and the shooter was killed when a school resource officer confronted him moments after the gunfire erupted.

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, but the officer was credited with preventing any more loss of life.

Deputies and federal agents converge on Great Mills High School, the scene of a shooting, Tuesday morning, March 20, 2018 in Great Mills, Md. The shooting left three people injured including the shooter. Authorities said the situation was "contained." (AP Photo/Alex Brandon )

Authorities didn't release a motive, but said they believe the girl and the shooter — 17-year-old Austin Rollins — previously had a relationship.

A 14-year-old boy also suffered a gunshot wound, but it wasn't clear who shot him. He was in good condition.

The officer, who doubles as a SWAT team member, was unharmed.

The shooting at Great Mills High School rocked a nation still reeling from the Feb. 14 massacre of 17 people at a Florida high school by a teenage boy with an assault weapon. Students across the country have planned an anti-gun violence march this weekend at the nation's capital.

Politicians responded swiftly to the Maryland shooting, acknowledging that it increased the pressure for action.

"We sympathize. We empathize. We have moments of silence. But we don't have action," said the No. 2 U.S. House Democrat, Steny Hoyer, who represents the area in Congress. "Wringing our hands is not enough."

In this case, it appeared the shooter illegally possessed the gun. In Maryland, a person must be 21 to possess a handgun, unless carrying one is required for employment. It's not clear how Rollins obtained the weapon.

Attempts to reach his family were unsuccessful.

One of the shooter's friends, 14-year-old Jordan Hutchinson, and his mother dropped off a condolence card at the Rollins home.

Jordan recalled meeting Austin five years ago during a snow storm, and playing together building snow forts.

"Austin was a nice kid. We did sleepovers all the time," he said.

The sheriff praised the school resource officer, Deputy First Class Blaine Gaskill, a six-year veteran in his first year at the high school, for containing the situation in less than a minute.

"He had to cover significant ground," Cameron said. "The premise is simple: You go to the sound of gunfire."

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 and taken to another school to be reunited with their parents.

The school has about 1,600 students and is near the Patuxent River Naval Air Station, about 65 miles (104 kilometers) southeast of Washington.

Sen. Ben Cardin, D-Md., said at a minimum, universal background checks and a ban on assault-style weapons are needed. He said he believes momentum is building for reform, fueled by student activism.

"I can tell you that Americans are listening to our students. I think our political system will respond," he said.

Maryland's Senate joined the House on Monday night to ban bump stocks, which enable a semi-automatic rifle to mimic a fully automatic weapon. Teachers' union leaders issued statements Tuesday saying more policies must be changed nationwide to keep schools safe.

Republican Gov. Larry Hogan, meanwhile, accused the Democrat-led legislature of failing to take action on "one of the most aggressive school safety plans in the country." It commits $125 million for capital improvements such secure doors and windows, metal detectors and security cameras. It also includes another $50 million annually to pay for school resource officers, counselors and technology.

Hogan said "it's outrageous that we haven't taken action yet," with less than three weeks left in the session.

House Speaker Michael Busch, a Democrat, said legislators have "every intention" of passing legislation to make schools safer.

Just last month, the St. Mary's County sheriff's office said it arrested two teenage boys for "threats of mass violence" and a 39-year-old man on related charges after the teens made threats about a potential school shooting at Leonardtown High School. Police said they obtained a search warrant that led to them finding semi-automatic rifles, handguns and other weapons, along with ammunition.

"This is what we prepare for and this is what we pray we will never have to do," the sheriff said Tuesday. "The notion that it can't happen here is no longer a notion."

Video shows police officers responding to shooting at Great Mills High School in Maryland. “The event is contained,” according to the school district. https://t.co/p6ZPCw44RZ pic.twitter.com/m9TMfrSjyi — ABC News (@ABC) March 20, 2018

Multiple people were injured in a shooting at Great Mills High School in southeast Maryland this morning, the St. Mary’s County sheriff’s office confirmed. Stay with News4 for more on this developing story. https://t.co/sKHAUL1c0F pic.twitter.com/5ILb4gtAjO — NBCWashington (@nbcwashington) March 20, 2018