You might assume that there's a clear demarcation between science fiction and fantasy, but in fact, the dividing line is fuzzy. When I was young, I satisfied a lot of my taste for both genres by reading the Fantasy and Science Fiction mag. That magazine's very name suggested that there was a common audience for both types, and perhaps it also reflected the editors' desire to avoid deciding which was which. Today, it appears that there's a much greater audience for science fiction, and so the question of which is which becomes more relevant.
Now here's an obvious way to decide, but for me, it often fails to work: Science fiction deals with the future, with modes of science, transportation, robotics, communications and gunnery so far uninvented or uninventable. The rest of fiction, if not realistic, is fantasy. I recently read what is clearly a marketed as a fantasy novel, but after awhile, it became science fiction for me. In this novel, the great conceit is that the Horn of Merlin lies at the bottom of the sea and works its magic on all around it, giving the plants, creatures and even nearby humans a sort of immortality. You can see this immortality in the way their DNA has changed, giving them the ability to always heal themselves. On this matter, and several related magical ones, the author bores me to tears by trying to explain how, scientifically, these things could REALLY HAPPEN.
Here's a my dividing line: In science fiction, the author tries to persuade you that no matter how outlandish matters are, they are just a few scientific breakthroughs from what we know today. In fantasy, the author introduces some preposterous concepts and requests your “willing suspension of disbelief.” And please notice, my definition dovetails nicely with the words “science fiction:” This is a field of fiction that pretends to base itself on science.