County police said the wounded Perry Hall High School student was flown to a hospital. The 17-year-old male student was in critical condition at Maryland Shock Trauma Center, a hospital spokeswoman said.
No one else was reported injured.
A male suspect was taken into custody after the shooting, police said. The suspect is a student, but police did not say where he attended school.
The school was evacuated, and students were being escorted to a nearby shopping center and middle school.
WJZ-TV showed video of a shirtless male with his hands behind his back being put into a police cruiser.
Perry Hall is a middle-class community along the Interstate 95 corridor, northeast of Baltimore city. The school is the largest in the county, with 2,200 students.
County Councilman David Marks, who lives next door to the school, said he had received dozens of phone calls and text messages from worried parents and residents.
“This is a very comfortable, very safe community, and it’s an excellent high school,” said Marks, who graduated from Perry Hall. “I think this is an aberration, but clearly one that is horrifying, particularly on the first day of school.”
Television coverage showed scores of police cars surrounding the school and parked on neighborhood streets. A group of officers with weapons drawn staked out a corner of the building, one of them lying prone on the ground and appearing to cover a particular area of the campus. Hundreds of students streamed away from the school toward a nearby shopping center where they met their parents.
Two students who spoke with WBAL-TV described hearing a popping sound in the cafeteria and initially thinking someone was playing a prank. One student said she then saw the shooter with a gun near the vending machines and that a guidance counselor then got the suspect up against the machines and got the gun away from him. The students described some people running from the cafeteria, while others ducked under tables.