If it doesn't take place in our world. It's fantasy. It might be realistic and very closely parallel to ours but still fantasy. This can include fantastic worlds with aspect impossible in our reality. Magic, fairies, orcs, dragons. It can also just be a realistic world like ours but different with nations and cultures that don't exist. Tolkien, Eddings, Martin write fantasy. Anything that pretends to be historical but includes Magic/dragons/ zombies are fantasy.
Historical fiction takes place in OUR history, and may alter details and facts to suit the plot but not much. It either plays fast and loose with historical people's lives OR interjects fictional characters into historical events. Bernard Cornwell writes historical fiction.
Related, but distinct I feel, to historical fiction are the alternative history novels. Maybe then cross the fantasy/historical/Sci Fi divide. These are basically realistic history with a point of divergence from which the author fantasizes a new history. A story set in a world in which Germany won ww2 or one where India colonised the US first for example. Harry Turtledove is the prime example.