German police said Thursday that a 15-year-old student had been shot dead at a special education school in the southwestern town of Offenburg.
The suspected shooter, another 15-year-old student at the school, was detained during a large-scale police operation.
He was remanded in custody on suspicion of manslaughter, police and prosecutors said.
The attack is said to have taken place in the suspect's 9th grade class, Germany's dpa news agency reported.
At the time of the shooting, 180 students were evacuated from the premises and picked up by their parents.
Police suspect 'personal motive'
According to the investigators, the attacker is said to have entered a classroom at lunchtime, approached the classmate sitting inside and opened fire with a handgun. The victim later died of the wound in hospital.
Police and prosecutors believe the suspect acted alone and said initial findings revealed a previous relationship between the alleged perpetrator and victim.
A "personal motive" is suspected in the dispute between the two minors, police and prosecutors said.
Thursday's attack came a day after two children threatened a teacher with a gun at a school in the northern port city of Hamburg. No one was injured in that incident.