German prosecutors said that police had rescued a 13-year-old girl and detained a man accused of kidnapping and sexually abusing her after they followed up a written plea for help that the child apparently threw out the window.
The man is to appear before a judge today.
The girl had been missing since January 11, when she vanished on her way to school.
Police said that yesterday a man found a note near some rubbish bins in which the girl begged the finder to alert the police.
She included the address where she was being held, only about half a mile from her home.
The 35-year-old man, whose name was not immediately released, had been holding her against her will in his Dresden apartment and abusing her for five weeks, said Christian Avenarius, a spokesman for prosecutors in the city.