The teenager entered the Carolinum High School in the Bavarian town of Ansbach on Thursday morning and threw one Molotov cocktail before police were alerted and arrived at the scene, said Bavarian Interior Minister Joachim Herrmann.
Police smelled smoke when they arrived at the school, Hermann said. They were confronted by the ax-wielding teen, who had thrown a second Molotov cocktail that apparently failed to detonate.
"Since the attacker threatened to use his weapons against the police, the officers opened fire," Hermann said, adding that the attacker, who was not identified, was wounded and in critical condition.
Udo Dreher, the chief police officer at the scene, said the18 year old was shot five times, but was not in life threatening condition.
Two teenage girls were seriously injured by the attacker - one suffering burns and the other head injuries, said Dreher. It was not immediately clear whether the second girl was attacked with the ax or a knife. Authorities did not say how the other seven wounded students had been attacked.
Dreher said the assailant started his rampage armed with three Molotov cocktails, the ax and two knives. He was arrested 11 minutes after police were called to the scene.
Authorities said the teen had no police record and it was not immediately clear what his motive might have been. Officials said there was no indication that he had said anything during the attack.
Fire service official Horst Settler said no major fires broke out in the school and its roughly 700 students were evacuated and taken to a nearby building.
Prosecutor Gudrun Lehnberger said the 18-year-old male student at the school was being held on suspicion of attempted murder. Lehnberger said the initial investigation would concentrate on determining a motive for the attack, which came only three days after the new school year started in Bavaria.
According to its Web site, Carolinum was founded in 1528, making it the second-oldest public high school in Bavaria. Today, the school offers curriculum based on the humanities and music for grades five through 13.
The incident was the second attack on a school in Germany this year.
In March, 17-year-old Tim Kretschmer fatally shot 12 people at his former school in the southwestern town of Winnenden. He fled the building and killed three more people before turning the gun on himself.
That was the nation's second-worst school shooting after a 2002 shooting spree in Erfurt that left 17 dead, including the gunman.
After Kretschmer's attack in Winnenden, Germany moved to tighten checks on gun owners.