The speaker introduces the lovely river town of Hamelin in Brunswick and tells of its serious vermin problem 500 years before. Rats had overrun the city, to the point that the public demanded of the Mayor and "our Corporation" that the rats be destroyed or else the people would remove them from power.
The Mayor and Corporation have a stressful meeting, but can discover no viable option until "the strangest figure" arrives. He is extremely gangly, garbed in bizarrely colored clothing, and old-fashioned. They also notice he has a flute hanging around his neck, which he continues to finger while they talk. He explains that he has heard of their problem and has a "secret charm" that leads creatures to follow him when he wants. He says he uses his talent "on creatures that do people harm" and asks for one thousand gilders if he can rid the town of rats. They quickly up his offer to 50,000 gilders.
The piper heads outside and begins to play his flute. Almost immediately, the rats come out from everywhere and follow him as he plays and dances through the streets, until he finally gets to the river and leads them all to their deaths by drowning. Only one rat escapes, and the speaker tells how that rat swam to family and told the story of the Piper for the rest of his days.
Hamelin is overjoyed and immediately sets to repairing itself, but the Piper interrupts their merriment to request his 1,000 gilders. The Mayor and Corporation, suddenly wondering whether they ought to pay a vagabond such money, apologize patronizingly and then offer him only 50 gilders. Angry, the Piper makes a veiled threat, but the Mayor blows him off.
The Piper heads out into the street and again begins to play his flute. However, this time it is not rats, but the children of the town who begin to follow him. The adults find themselves unable to move as they watch the children dancing along behind the Piper as he heads out of town. Finally, the adults are able to move and decide to follow at a distance, assuming he will sooner or later have to stop playing. But when the Piper reaches a nearby mountain, a magic portal opens and all the children disappear with him into it. The speaker then tells of one boy, whose lame foot prohibited him from keeping up and who was thus left behind. He remains sad and distraught the rest of his days for not having glimpsed whatever promise lay in the Piper's song.
Hamelin, having suffered a great tragedy in losing all its children, tried to send word to the Piper that they would pay his fee, but to no avail. They made laws to commemorate the memories of the children and have rebuilt since then. The speaker adds a note that there is a "tribe of alien people" in Transylvania whose legends tell how their forbearers once rose "out of some subterranean prison," though nobody in the tribe understands the meaning of the legend.
The final short stanza is addressed to "Willy," and the speaker insists upon the importance of keeping promises.
This wonderful poem is perhaps most notable for its playfulness. It uses a delightful and simple rhyme scheme, and the length of each stanza varies so that the story's rhythm is constantly changing. Mostly, it follows the classic fairy tale of the Pied Piper, keeping to the same two morals.
The first moral is: "If we've promised them ought, let us keep our promise." Simply put, a man ought to keep his word. When the Mayor and Corporation failed to deliver to the Pied Piper what he had earned, they were counting on their power and authority to save them from any retribution, but of course discovered the opposite to be true.
The second moral appears in the penultimate stanza: "Heaven's gate/Opens to the rich at an easy rate/As the needle's eye takes a camel in!" A paraphrase of the Biblical verse that makes wealth and holiness mutually exclusive, this poem suggests that concerns with worldly goods – money and power – will pollute a person. Notice that, even before the Mayor and Corporation betray the Piper, their concern for the town does not flare up until the public threatens rebellion. Those who hired the Piper were solely concerned with material life, and their decisions ended up costing the entire town its happiness.
The poem subtly makes a comment on economics and politics in this way. First, the use of the word "Corporation" makes the poem more updated than the classic tale. The suggestion is that a population is ruled not only by its government (personified by the Mayor) but also its economic systems (represented by the Corporation). In the poem, these entities do not control the population through deceit but rather with the support of the population. The people in this poem are content to stay quiet until their safety is explicitly threatened, at which point they make demands of the Mayor and Corporation. Considering that Browning lived in an age of European revolutions, it is an interesting element that seeps in and makes the poem contemporary to his Victorian period.
Finally, one can also see in this poem Browning's fascination with artists and their relationships to their public. In this poem, the Piper is remarkable not only for his talent, but because he is able to achieve his "charm" not through magic but simply by the profundity of his musical talent. In his song, the children are not duped but rather believe in a wonderful world, suggesting the power of art to evoke in us wonderful visions. However, the flip side is that the misuse and disrespect of art can make life all the more terrible. Not only was the Piper betrayed in terms of money, but his art was not respected fully; rather it was treated as a tool. When this happens, he shows the town how terrible that tool can be if the artist is not given due credit for his abilities. Though the poem is not entirely shaped in this direction, it is an intriguing way to link this lovely little children's poem into one of Browning's most pervasive fascinations.