The Maryland high school student who fatally shot his ex-girlfriend and injured another student also killed himself, authorities said.

Austin Rollins, 17, shot himself in the head when he was confronted by school resource officer Blaine Gaskill during the March 20 school shooting, the St. Mary’s County Sheriff’s Office said Monday.

Gaskill had arrived within a minute of Rollins shooting 16-year-old Jaelynn Willey in a hallway at Great Mills High School. A shot Gaskill fired struck the Glock handgun in Rollins’ hand.

Rollins held the gun, which Gaskill had ordered him to drop, to his head, student witnesses told WJLA.

Gaskill was not injured.

The teen girl was left brain-dead and taken off life support two days after the attack.

Desmond Barnes, a 14-year-old victim, was shot in his right thigh in the same hallway as Willey.

“I was just shot at my school,” he said in a 911 call released Monday, where he had to repeat himself to the dispatcher, saying again, “I was just shot at my school.”

Investigators said the single shot fired by Rollins hit both Willey and Barnes.

The Glock that Rollins used was legally owned by his father.

The sheriff’s office said Rollins “had a prior relationship which recently ended” with Willey.