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.
The 16-year-old girl was hospitalized with a life-threatening wound, the sheriff said. A 14-year-old boy also suffered a gunshot wound, but it wasn't clear who shot him. He was in stable condition. The officer, who doubles as a SWAT team member, was unharmed.
Politicians responded swiftly, acknowledging that this shooting increases the pressure for action against gun violence as anger swells nationwide over the Valentine's Day killings of 17 people at a Florida high school 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. The shooter was identified 17-year-old Austin Rollins.
Authorities believe he had a prior relationship with the girl but a motive wasn't immediately clear.
There has been an incident at Great Mills High School. Parents please DO NOT respond to the school. Report to Leonardtown High School— St. Mary's Sheriff (@firstsheriff) March 20, 2018
The sheriff praised the officer, Deputy 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."
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, about 65 miles (104 kilometers) southeast of Washington. On Tuesday, ambulances, fire trucks 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."
Sen. Ben Cardin, D-Md., also spoke to reporters near the high school, saying that 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."
Many students across the country are calling for effective gun controls, leading up to Saturday's March For Our Lives rally in the nation's capital against gun violence in schools. The violence hasn't abated since the massacre in Parkland, Florida. A high school student in Birmingham, Alabama, was killed this month when a classmate fired a gun inside a classroom. Threats against schools have proliferated as well, and Great Mills High has not been immune.
Just last month, the school's principal, Jake Heibel, told parents in a letter posted on the local news site The Bay Net that two students were interviewed after they were overheard mentioning a school shooting, and they were found to pose no threat. Heibel said the school increased its security nevertheless after social media posts about a possible school shooting "circulated quite extensively."
Also last month, 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, a high school about 10 miles from Great Mills. 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."
Maryland Governor Larry Hogan issued this statement:
" ... I want to express my deepest gratitude to the St. Mary's County Sheriff's Office and all of the first responders who swiftly and bravely took action to secure the school. The First Lady and I are praying for those who were injured, their families and loved ones, and for the entire Great Mills community as they come together to heal in the wake of this horrific situation. But prayers are not enough. 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."