It was originally a novel by Gaston Leroux, published in 1910, and has since been adapted into numerous other forms, including the famous Andrew Lloyd Webber musical.
While some elements of the story, such as the Paris Opera House and the existence of a real person named Erik (though not with the same characteristics as the Phantom), are based on reality, the story itself is a fictional creation.