Perhaps the basilisk could be a creation of an evil wizard in Middle - earth who has dabbled in dark magic similar to that in Harry Potter. It could be hidden in the depths of Mordor or some other dark place, waiting to be unleashed on the unsuspecting heroes.
One way it could fit is if the basilisk was a relic from an earlier age in Middle - earth. Just like there are ancient evils in Lord of the Rings, the basilisk could be one that has been dormant for a long time. When it awakens, it could cause chaos among the different races. The elves might have some knowledge of how to combat it, as they are often associated with ancient magic and lore.