The man stormed into the Geschwister Scholl school in Emsdetten, near the Dutch border, at about 9:30 a.m. (0830 GMT) and fired several shots, police said. Among the injured were several students, a female teacher and the head caretaker.
Police spokesman Klaus Laackmann said the injuries were all minor.
It was not immediately clear how the assailant died, but Laackmann said the school had been cleared and the students taken to safety, reports AP.
"The building is clear, all the children are safe, the perpetrator is dead," Laackmann said, adding that explosives were found near the man's body.
He would not elaborate on whether the man killed himself or whether he was killed by police.
N-tv television reported the assailant was an 18-year-old former student of the school.