Everybody has (sort of) heard of Faust, who made a deal with the devil in Goethe's book, in order to gain power and strength and the woman he loved. Gounod wrote an opera about Faust, and Berlioz wrote a concert piece about Faust's resulting damnation.
The idea of making a deal with the devil is certainly an intriguing one. I've used it myself in my novel A Bad Spell in Yurt. But are such deals medieval? (Faust is always portrayed as sort of medieval-looking.) Actually not.
One did not in fact "deal" with the devil in medieval theology. Demons came and tempted people into sinning, but mostly they did horrible things to them, tormented them and poked them and carried their souls away with evil laughs.
By the late Middle Ages, however, particularly wicked people were considered to consort with demons, riding around with them at night and having sex with them. Joan of Arc in the fifteenth century was accused of witchcraft, but she got off because she was proven to be still a virgin, having thus clearly never had sex with demons. (So they burned her for heresy instead.)
An influential book of the fifteenth century on demons and witches, written by someone we would consider seriously disturbed, was one of the earliest books printed with the invention of the printing press. It stressed that sinners liked carrying on with demons (twelfth-century sinners, as in the carving illustrated above, hated doing so because it was extremely unpleasant). In the sixteenth century, with the Protestant Reformation, when Protestants and Catholics decided the others were heretics, they accused each other of being witches and demon-lovers.
By the seventeenth century, after all the destruction of the wars of religion, countries mostly settled down to have just one religion. Now accusations of witchcraft and demon-consorting were used not against people of other religions but people of one's own religion, who seemed scary or weird or different somehow. This was the age of the Salem witch trials in the American colonies. Witch trials, note, were extremely rare before the seventeenth century.
The Enlightenment of the eighteenth century led to the educated deciding that there were no such things as demons and witches, and that these were fables for the unsophisticated. (Medieval educated people, in contrast, had been very concerned about demons.) Thus, when Goethe began writing his Faust around the beginning of the nineteenth century, he could use demons and the devil himself not as creatures of objective reality but rather as metaphors for dark desires and innate sinfulness.
In many ways the nineteenth century, including those who later set Faust to music and composers like Wagner, were trying to struggle with the same ideas Freud did, but Freud hadn't come along quite yet. Emerging was the idea, that in a post-Freud world we now take for granted, of the darkness possible in the human id and ego. So Goethe was asking what someone would be willing to do, what would he sacrifice to get what he most desired.
In the twentieth and twenty-first centuries, with the development of fantasy and science fiction, we have a whole genre of metaphor. People (like me) who write about wizards and witches aren't really writing about magic systems in which we believe. Instead we are commenting on the human condition and the results of power and stark choices, wrapping it up in an exciting adventure. Setting it in some version of the Middle Ages (for fantasy) or an imagined future (for science fiction) just makes it more cool.