A gunman who opened fire at Great Mills High School in Maryland was killed Tuesday after engaging an armed school resource officer, authorities said.

The shooter, Austin Wyatt Rollins, 17, was the only fatality. Police said Rollins used a handgun to shoot a 16-year-old female student, who was identified by family members as Jaelynn Willey. She remains in the ICU with life-threatening, critical injuries.

A 14-year-old male student was also shot and is in stable condition.

St. Mary's County Sheriff Tim Cameron said there were indications Rollins and the female victim had a prior relationship, which police are investigating as a possible motive for the incident.

The school resource officer, Deputy Blaine Gaskill, was alerted of the shooting, immediately responded and engaged the shooter. Gaskill, who is also a SWAT team member, was not injured in the shooting.

"Our school resource officer was alerted to the event. He pursued the shooter, engaged the shooter, fired a round at the shooter," Cameron said. "The shooter fired a round as well. In the hours and days to come, we'll be able to determine if our school resource officer's round struck the shooter."

Cameron said police were investigating if the shots fired killed Rollins or if he committed suicide.

Maryland Gov. Larry Hogan called the shooting "tragic" and accused the Democrat-led legislature of failing to take action on "one of the aggressive school safety plans in the country."

"We need more than prayers, we gotta take action," Hogan said. "We got one of the most aggressive school safety plans in America that we introduced a few years ago. We've got to take action. We're going to try to get something done in Annapolis."

Cameron said the entire incident played out in about a minute Tuesday morning and Gaskill did everything he was supposed to do in an active shooting situation. Police are currently reviewing surveillance video from the school to determine the exact timeline of the incident.

Cameron said officials were looking into Rollins' phone, social media and room but have not yet found any warning signs the shooting was imminent.

Earlier, the school was placed on lockdown and students were evacuated to Leonardtown High School to be reunited with their parents.

The Maryland State Police along with the FBI and agents from the Bureau of Alcohol, Tobacco and Firearms are on the scene assisting with the investigation. The scene at the school, which has about 1,600 students and is near the Patuxent River Naval Air Station, was said to be "contained."

President Trump was notified of the shooting, press secretary Sarah Sanders told Fox News.

Ziyanna Williams, a student at the school, said her fellow students were cowered in classrooms as police came inside the room to evacuate the building.

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

Terrence Rhames, 18, a student at the school, told the Baltimore Sun he was standing with friends before class began when he heard a gunshot. He said he started to run and believed he saw a girl fall nearby.

“I just thank God I’m safe,” Rhames said. “I just want to know who did it and who got injured."

Willey, the student in life-threatening condition, remains in the intensive care unit at the University of Maryland Prince George's Hospital Center, Fox 5 DC reported. A YouCaring fundraising page raised more than $26,000 as of 8 p.m. Tuesday night.

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. They were later 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, 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, 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.

The school is located about 60 miles from Washington, D.C. The St. Mary’s County Public Schools tweeted counselors and support staff would be on hand at Leonardtown High School.

The incident comes more than a month after the school shooting at Marjory Stoneman Douglas High School in Parkland, Florida. That massacre, carried out by a former student, left 17 people dead. The shooting also comes days before some 500,000 people were expected to march Saturday in Washington, D.C. to protest gun violence and push for gun control legislation.

Fox News' Nicole Darrah and The Associated Press contributed to this report.