The large generic term for this film is “fantasy” but more specifically, it is an “imaginative world” fantasy, or sometimes called a “labyrinth” fantasy, in which a central character is involuntarily trapped in a self-logical system with other characters who live in and understand the “non-rules” of that system. The best-known of these is “Alice in Wonderland” (of course a piece of literature long before a film). The features of the genre are that an innocent person is accidentally submitted to a world where the learned “rules” of youth (logic, gravity, social behavior, and the like) are suspended, and the imagination of a “ruling figure” is the only limit to what can occur. Pan’s Labyrinth conforms to the expectations of this genre, “the world" of the magic show, Ofelia’s attempts to escape, etc. Another feature of this genre is “the quest”—the seeking to escape is accompanied by an urge to fulfill some goal. This genre includes such films as the Indiana Jones series, where the world is an ancient civilization; not exactly science fiction (which projects a future technological world), but an archeological fiction, where ancient civilizations embellished by imagination are the setting.
Labyrinth motifs are an expected part of this genre—getting out is a puzzle in which logic is not always the solution. But one unexpected element is the absence of Pan as a character; instead “his” labyrinth is the maze of pleasures, drunken madness, self-indulgence, hedonism that the God-figure Pan (Bacchus) represents.
The technological tricks of film-making--editing, time-altering, selective imagery, juxtaposition of scenes, etc. all make the genre particularily attractive to experimental film-makers.