I’ve never seen a book of Fantasy where magic wasn’t governed by laws or physics of some sort. The more detailed, well-defined and unbreakable the laws are, generally the better the book. Mistborn is a prime example of this, where all of the “magic” (Allomancy, Feruchemy, and the evil Hemalurgy) that can be used, all of the effects and all of the different combinations, and the people that can use them, are laid out in a graph in the front of the book - that way, the author can’t use a previously unknown mega-spell as a deus ex machina.
As I said in my first place, it’s a substitute for high technology when the book is written in a different era or strange world.
Very few books (the only one that I can think of personally is Johannes Cabal, and I’ve read most fantasy books out there, at least high fantasy and sword and sorcery: I don’t read vampire books, werewolfe books, horror, HP Lovecraft, etc. - when it comes to HP Lovecraft, from what I know, those books truly are demonic*) have any sort of dealing with the devil in the sense that you’re speaking of (often, there are many gods, in a world without one God, but, as long as it’s kept separate from reality, I don’t see the difference, like the Ainur in LotR; the world is fiction, so it doesn’t have to reflect the laws or metaphysics of our world: as JRR Tolkien said, and he was a conservative in such matters, something to the effect of, “I wrote thinking of what could have been, if God had governed differently”), and those that do are generally of the most despicable character (Bauchelain and Korbal Broach, Voldemort, the Forsaken), but their misfortunes are often used as dark humor and horror (Johannes Cabal), but rarely as anti-heroes.
*Note: there are those books that some would call Fantasy, such as HP Lovecraft, Aleister Crowley, Helena Blavatsky, Elizabeth Clare Prophet, and other works associated with Gnosticism/Thelema/Theosophy are truly evil, which comes to from their being called Fantasy, but from the fact that some people believe they represent actual real-world application and false, Satanic worship and religion.
However, I would put this in the category “false religious works”, and would rank other such, such as the Book of Mormon, the Book of Moses, the Nag Hammadi Library, Hermes Trismegistus, the Book of Abraham, various Grimoires/Keys of Solomon, the Sixth and Seventh Books of Moses, the Koran, the Urantia Book, etc. in this category. I suppose they can be called Fantasy in a sense, because false religion is Fantasy, as our own most holy and true religion is fantastic, and the false religions inevitably copy it.
Even in that case, I believe that heretical antilegomena and apocryphal books written in the Biblical style by members of cults such as the Sethians, Manichees, Valentinians, etc. can be useful in a proper historical context, but for scholarly study, not for fun reading.