She agreed to pay a €400 fine to the Wiesbaden district court in Wiesbaden in return for the prosecutor's office dropping charges of causing personal offence, a spokesman said.
The teacher had wanted to draw attention to how inappropriate the student's clothing was for school, he said.
The 15-year-old girl's clothing had become such a distraction for boys during class meetings, that she had been told to dress more moderately, the Wiesbadener Kurier newspaper reported.
But she refused to change her clothes – and her mother backed her up when school officials approached her.
After the pencil incident, the girl tried to start a campaign on the internet for the teacher to be made to leave the school banned from working as a teacher, the paper said.
"I will finish her," the girl was reported to have posted. As a result, the student herself was also judged to have crossed the line. She was made to do 10 hours work community work and has been moved to another class.
The state education office is still examining whether the teacher's behaviour should have further consequences.
Story continues below…