In a previous article I wrote about what makes fantasy different from science-fiction. Fantasy is limitless, it is magical, science-fiction has restrictions, limits and constraints just as real life.
However, a novel later developed into a series comes to my mind, The Magic Goes Away by Larry Niven. Though it is still quite unrealistic, it does have one important feature of a science-fiction novel, magic is becoming scarce because it has been overused. This restriction places this novel just a little bit away from pure fantasy, not anything can just happen on a whim, there are rules and limits, in this case a limited quantity. Then you avoid issues like the omnipotence paradox: can an omnipotent being create a wall it cannot break through?