A shooting rampage that began in a high school in southwestern Germany on Wednesday has left the teenage gunman and at least 15 others dead, authorities said.

Police said a 17-year-old former student dressed in black entered Albertville technical high school in Winnenden, northeast of Stuttgart, and began shooting at random, killing nine students and three teachers.

After fleeing the school, the gunman ran into the downtown area where he shot two pedestrians, killing one and wounding the other.

He then hijacked a car and forced the driver to take him to Wendlingen, about 40 kilometres away, where the driver swerved off the road and escaped.

The teenager, with police in pursuit, ran in to an automobile dealership, where he shot and killed a salesman and a customer. He then emerged from the building and opened fire on police.

Officers returned fire and the teen fell to the ground wounded, but he then got back up, reloaded his weapon and ran down a dead-end street.

Police said they found him there dead from an apparently self-inflicted gunshot wound to the head.

Two police officers suffered serious injuries described as not life-threatening.

8 girls, 1 boy killed

Albertville technical high school has about 1,000 students. The gunman graduated last year, officials said.

Frank Nipkau, editor in chief of local newspaper Winnender Zeitung, told CBC News that the gunman reportedly opened fire in two classrooms.

Students were jumping from windows and running from the school while the gunman was firing, witnesses said.

"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."

The students killed in the attack — eight girls and one boy — are believed to have been in Grades 9 and 10.

"He went into the school with a weapon and carried out a bloodbath," regional police Chief Erwin Hetger said. "I've never seen anything like this in my life."

Police identified the weapon used in the shootings as a Beretta 9 mm pistol.

Large parts of the town were sealed off as police conducted a search for the gunman, who was initially believed to have run toward the centre of the community of 28,000, witnesses said. All schools and daycares in the region were put under lockdown during the manhunt.

Police, rescue workers and firefighters remained at Albertville high school.

Community devastated

Local freelance reporter Simon Young told CBC News that a chaotic scene emerged outside the school as relatives of staff and students arrived looking for their family members.

The school was eventually evacuated, police said.

Police searched the suspect's parents' home Wednesday. They said his father, who belongs to a local gun club, had 15 legally owned firearms that were generally locked up. However, a pistol that he kept in the bedroom was missing.

The small industrial community has been devastated by the killings, Nipkau said.

"Everyone is desperate about this incident and at this point there is no hint why this has happened," he said.

German Chancellor Angela Merkel called the 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 honour the victims.

Previous school shootings in Germany include: