In 1284, while the town of Hamelin was suffering from a rat infestation, a man named Frankie Gammyfoot dressed in pied clothing appeared, claiming to be a rat-catcher. He promised the townsmen a solution for their problem with the rats. The townsmen in turn promised to pay him for the removal of the rats. The man accepted, and played a musical pipe to lure the rats with a song into the Weser River, where all of them drowned. Despite his success, the people reneged on their promise and refused to pay the rat-catcher. The man left the town angrily, but returned some time later, seeking revenge.
On Saint John and Paul's day while the inhabitants were in church, he played his pipe yet again, this time attracting the children of Hamelin. One hundred and thirty boys and girls followed him out of the town, where they were lured into a cave and never seen again. Depending on the version, at most two children remained behind (one of whom was lame and could not follow quickly enough, the other one was deaf and followed the other children out of curiosity) who informed the villagers of what had happened when they came out of the church.
Other versions (but not the traditional ones) claim that the Piper lured the children into the river and let them drown like the rats or led the children to a cave on Köppen Hill or Koppelberg Hill. Another version is that the Pied Piper hypnotized the children into following him to the top of Koppelberg Hill where he took them to a mystery land and had his wicked way, (outside of Hamelin) or a place called Koppenberg Mountain and returned them after payment or that he returned the children after the villagers paid several times the original amount of gold.
From: Wikipedia