The 17-year-old had no criminal record and authorities say he was barely noticed in school until he returned Wednesday with a handgun and a purpose.
Entering the high school where he graduated last year, he burst into morning classes and opened fire, taking students and teachers by complete surprise.
"Children were sitting at their tables, with pencils still in their hands, their heads fallen over on the table," said regional police director Ralf Michelfelder, describing the grisly scene that his officers found. "Most of them had shots in their head — it must have all happened in seconds."
Police identified the gunman only as Tim K. But the name on the mailbox at his parent's home was Kretschmer and local media identified him as Tim Kretschmer.
Left a cache of ammunition
The suspect went to three classrooms, killing nine students and three teachers before fleeing the building when police arrived on the scene.
It was there the plan seemed to break down. Police said he left a cache of ammunition at the school, indicating that he had planned more killings there.
"I heard two shots and then screaming," said a 15-year-old student who gave her name only as Betty. "At first I thought it was a joke, but then someone called, 'Run, run!' and I saw students jumping out of the windows and took off running."
"Our officers were very quick," said Baden Wuerttemburg state interior minister Heribert Rech. "Through the immediate police intervention they were able to prevent a further escalation of the crime."
There was no immediate indication of motive, but the gunman's victims were primarily female: eight of nine students killed were girls, and all three teachers were women. Three men were killed later as the suspect fled.
Sabienne Boehm, 12, said she recently had met the shooter and that he had claimed fellow students at the high school had mocked him and teachers there ignored him.
Three weeks ago, she said, he showed her a note. "He wrote to his parents that he's suffering and he can't go on," she told the AP outside a memorial service at a town church late Wednesday.
The dark-haired teen, shown wearing glasses in pictures on German television, apparently took the weapon from his father's collection of 16 firearms along with a "multitude of ammunition," police said. His father was a member of the local gun club and kept all the weapons locked away except for the pistol, which was kept in the bedroom.
A 17-year-old who would give only his first name, Aki, said he had studied with the shooter at a private business school, and described him as a quiet, reserved person.
Aki said the two played poker together, both in person and online, as well as a multiplayer video game called "Counter-Strike" that involves killing people to complete missions.
"He was good," Aki said.
Teenagers were sobbing violently and clinging to each other as they left a church service to the victims Wednesday.
'Lower than average' student
Police said the suspect was a below-average student at the school of about 1,000 pupils, but managed to graduate last year.
"He was lower than average, and he wasn't engaged in school events," Michelfelder said.
A sister of the suspect still attends the school.
After fleeing the school, the suspect ran into downtown Winnenden, a town of 28,000, where he shot two people walking by a psychiatric clinic, killing one and injuring the other, police said.
The gunman then hijacked a car and forced the driver to head south while threatening his life from the back seat, triggering a land and air manhunt involving 700 police officers and four helicopters, according to Stuttgart prosecutors, who are leading the investigation.
The driver swerved off the road to avoid a police checkpoint and managed to escape, while the suspect fled into an industrial area in the town of Wendlingen, about 24 miles from Winnenden.
He entered a car dealership, where he shot and killed his final victims — a salesman and a man shopping for a car — and then went back outside, prosecutors said.
He opened fire on police swarming the area. They shot back and hit the suspect, who fell to the ground, Michelfelder said.
But he got back up, reloaded his weapon, and fled into what turned out to be a dead-end street. Police found him there dead, having apparently shot himself in the head.
Almost Germany's worst school shooting
Two police officers suffered serious, but not life-threatening, injuries.
The death toll was close to that of Germany's worst school shooting.
In the 2002 shooting, 19-year-old Robert Steinhaeuser shot and killed 12 teachers, a secretary, two students and a police officer before turning his gun on himself in the Gutenberg high school in Erfurt, in eastern Germany.
Steinhaeuser, who had been expelled for forging a doctor's note, was a gun club member licensed to own weapons. The attack led Germany to raise the age for owning recreational firearms from 18 to 21.
German Chancellor Angel Merkel called the Wednesday shooting "a horrific crime."
"It is hard to put into words what happened today, but our sadness and sympathy goes out to the victims' families," Merkel said.
The European Parliament, meeting in Strasbourg, France, stood in silence for a minute, to honor the victims.
"It is our task as responsible politicians in the European Union and, indeed, all the member states to do our utmost that such deeds can be prevented," said EU assembly president Hans-Gert Pottering, a German.
More on Germany