"The Devil and Tom Walker" is most directly based upon the story of Faust, a folktale, and perhaps more specifically upon the popularity of the story's fundamental elements as fostered by the German author Goethe's play Faust, the first and more "traditional" part of which was written and performed around the time that Irving wrote his story.
Irving was traveling across Germany in an effort to gather new material and struggle through a writer's block that was preventing him from following up on an earlier series of successful short story collections. Faust is a German legend in that its origins are uncertain and it is attributed to no one person, and the exact form of the legend changes.
The essential elements are that Faust is a scholar who is frustrated with the limits of earthly knowledge and life, and seeks greater power through magic. The Devil, in a form that goes by the name Mephistopheles, offers Faust this power, in exchange for Faust's soul when he dies. Faust agrees, and lives a life devoted to "earthly" knowledge, and is then taken by Mephistopheles when he dies.
These elements remain in place in Irving's story, with Faust being replaced by Tom, although Tom is a considerably more corrupt character than Faust and desires money rather than knowledge. This may be part of the reason that the collection of stories that "The Devil and Tom Walker" was published with were criticized at the time - the similarities to Faust were too obvious, and by reducing Tom's motivations from knowledge to money, much of the original moral element is also reduced. The original carries a moral that is similar to that of the Adam and Eve story of the Bible; knowledge that is beyond God's permission leads to ruin.