The school day had barely begun when the student, who has not been identified, shot a male and a female student at Great Mills High School in St Mary's County before the campus security officer intervened, county Sheriff Timothy Cameron told NBC's Washington affiliate.
The two victims were in critical condition at hospitals.
The officer was not harmed, and the public school's roughly 1,600 students were later escorted off campus by police, classroom by classroom, to reunite with their parents at another high school.
The shooting took place at Great Mills High School in St. Mary's County, about 70 miles (110 km) south of Washington.
The sheriff's office confirmed an incident at the school and urged parents in a Twitter post not to approach the campus.
17 killed in Florida school shooting by former student: Sheriff
It occurred amid a re-energised national debate over school shootings in the United States following an attack on February 14 at Marjory Stoneman Douglas High School in Parkland, Florida, where a gunman killed 17 students and faculty.
The shooting came four days before the March For Our Lives -- partly organised by student survivors of the Parkland rampage -- takes place in Washington to urge lawmakers to pass tighter gun control laws.
A student who said his name was Jonathan Freese said in a telephone interview on CNN that he had been on lockdown with classmates for nearly an hour, but he did not hear gunshots himself. The interview ended as police came to his classroom door.
Maryland Governor Larry Hogan said he was monitoring events at the school. "Our prayers are with students, school personnel, and first responders," he said in a statement.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ