The modern version of this is the "brain in vat" (i.e. how do we know we aren't just brains in vats of biochemicals being stimulated to simulate what we sense). Descartes' Demon moves with the times, except perhaps when it comes to fashion. In fact, he bares an uncanny ressemblance to René Descartes himself, except for the horns, and the brain in a vat, of course.
Prior to taking the methodological skepticism (or, in the lovelier original, doute hyperbolique) to its extreme, in the Demon, Descartes used the dream argument as a thought experiment. Do we know this reality we each observe and experience exists or is it nothing but a dream? He uses this to show that in fact we can distinguish dream from reality. In this argument he was preceeded by two millenia by Zhuangzi (庄子;), 4th century BCE Chinese philosopher, who wrote, amongst other things "Zhuangzi dreamed he was a butterfly", which I came across in Jorge Luis Borges' famous essay "A New Refutation of Time".
Once Zhuangzi dreamt he was a butterfly, a butterfly flitting and fluttering around, happy with himself and doing as he pleased. He didn't know he was Zhuangzi. Suddenly he woke up and there he was, solid and unmistakable Zhuangzi. But he didn't know if he was Zhuangzi who had dreamt he was a butterfly, or a butterfly dreaming he was Zhuangzi. Between Zhuangzi and a butterfly there must be some distinction! This is called the Transformation of Things. (2, tr. Burton Watson 1968:49)
This philosopher was influential to Zen.
It's little wonder that in more recent and contemporary culture, we are still fascinated by these ideas. Consider Tweedledee and Tweedledum's warning to Alice in Through the Looking-Glass that the Red King asleep in the grass is dreaming about her, and that if he were to wake up she would "go out—bang!—just like a candle." Or The Matrix, which directly alludes to Alice. Likewise "Abre Los Ojos" (Open Your Eyes) (or its American remake, Vanilla Sky). Also the brain in a vat specifically makes appearances everywhere from Star Trek to Donovan's Brain.
Descartes himself was quite the character, alarming to contemporaries, even the scientists and philosophers. He liked to stay in bed until noon. It seems the enthuasism of his last great patron, Queen Christiana of Sweden, who demanded early morning tutorial, may have killed him. The moral of the story kids: no good come from studying before noon. Also, it's fun to try and tie all one's favorite things together.
*Remember him? Maxwell's Demon fights entropy, rather than empiricism. I love these far-out gedenkenexperiments (or thought-experiments, but if you are trained in physics you take language cues from Einstein) of such solid rationalists. Maxwell's Demon is more benign... after all, he might yet save the Universe from heat death.
**Personally, I would translate malin in le malin génie as wicked, rather than evil. I associate the word with mischievious, clever elves in fairytales... a trickster rather than something you'd see on Supernatural.