The killer was expelled from the school several weeks ago, and was apparently seeking revenge.
The massacre took place in Erfurt, a small university town about 150 miles southwest of Berlin in former East Germany.
According to police, the gunman killed two pupils, a policeman and 14 teachers, before killing himself. The dead included two girls, 10 men and five women. The slain policeman who was among the first group of officers to charge into the building after a janitor called for help at about 11am local time, police said.
Hundreds of students from grades five through 12 were in the Johann Gutenberg High School at the time.
“I heard shooting and thought it was a joke,” Melanie Steinbrueck, 13, told Reuters. “But then I saw a teacher dead in the hallway in front of Room 209 and a gunman in black carrying a weapon.”
The gunman barricaded himself into a classroom and shot himself as commandos closed in on him.
German Chancellor Gerhard Schroeder said he was “staggered” by news of the rampage, and canceled an election campaign stop that was planned for Saturday.
The death toll — Germany’s worst mass murder since World War Two according to police — was more than the April 1999 massacre at Columbine High School in Colorado, in which two teenagers killed themselves and 13 others. In a 1996 Dunblane, Scotland shooting, a man killed 16 children, a teacher, and himself.
The school shooting occurred just hours before Germany’s parliament approved a bill strengthening the country’s gun control laws, which are already strict.
According to police, there are approximately 10 million legally owned guns in Germany, and estimates place the number of illegal firearms at about 20 million. Illegal firearms began pouring in from Eastern Europe since the fall of the Iron Curtain and from former Balkan war zones.