Speaking to an interviewer in 1993, Raul Ruiz explained, “My films are not fiction films but about fiction.” This statement comes as close as any to defining this prolific and playful Chilean-born filmmaker; still, it deals with only one aspect of his varied career.

Ruiz, who died in August at age 70, left behind a massive body of work totaling over 110 films—from children’s adventures to documentaries to puzzling experimental shorts to low-budget thrillers to adaptations of Hawthorne, Balzac, Kafka, Dante, Shakespeare, and Proust. His eclecticism was profound in both its scope and its agenda; unwilling to be pigeonholed, Ruiz approached cinema as a game in which new rules could be invented and discarded at will and old ones could—and should—be broken.

I can’t think of a better introduction to this major but underappreciated filmmaker than his Portuguese feature Mysteries of Lisbon, which opens this week at Music Box. The last film he managed to complete (a final feature, La Noche de Enfrente, is currently in post-production), Mysteries of Lisbon is rich with coincidences, plot twists, multiple narrators, disguises, and flashbacks-within-flashbacks. Every major character possesses at least two identities, and the story—which hopscotches around Europe in the early 19th and late 18th centuries—ropes in the Napoleonic Wars, pirates, a woman hellbent on avenging the death of her twin brother, and at least four different love triangles. Above all, Mysteries of Lisbon is about the mechanics of storytelling and imagination—in other words, how fiction works.

As with nearly all of Ruiz’s major films, an accurate synopsis is both impossible and beside the point. But most of what happens in Mysteries of Lisbon is at least tangentially related to João (João Luís Arrais), a bookish teenager who lives in a boarding school under the protection of a priest, Father Dinis (played by the diminutive but arresting Adriano Luz). João knows nothing of his family, not even his own last name; rumors as to his father’s identity circulate among the other students. After suffering a seizure during a fight with a bully, João falls into a delirium and is visited by a woman (Maria João Bastos) who refers to him as her son.

A few days later, Father Dinis takes João for a walk and they pass by a mansion. The priest explains that the woman who visited João was in fact his mother—but her husband, whom they encounter in the mansion’s courtyard, is not João’s father. This is the first in a chain of revelations involving João, his parents, his grandparents, Father Dinis and his family, and such seemingly peripheral characters as the roguish part-time pirate Alberto de Magalhães (Ricardo Pereira) and the mysterious French widow Elisa de Montfort (Clotilde Hesme), not to mention the characters’ past selves.

Despite a daunting length—4½ hours, not counting an intermission—Mysteries of Lisbon has a strong sense of momentum; it keeps moving forward even as the action routinely jumps back in time. In many ways, this makes it Ruiz’s most conventionally entertaining and accomplished film: driven by the lush score of Ruiz’s regular composer, Jorge Arriagada, it moves like a crazed soap opera (in fact, one of Ruiz’s first jobs was writing scripts for Mexican telenovelas, for which he reportedly smuggled in quotations from Ezra Pound and T.S. Eliot). Ruiz’s distinctive style—a cross between the labyrinthine storytelling of Jorge Luis Borges, the artificiality of late-period Alain Resnais, and the narrative and visual trickery of Orson Welles—is usually distinguished by its patchiness and clutter, but here it’s surprisingly elegant. The camera glides through walls, reframes scenes from unexpected angles, and pulls back to reveal servants listening in on their masters. By contrast, the sound design routinely mutes extras (who are still seen talking) and musicians (who are still seen playing) in order to focus attention on the dialogue. Everything is governed by an invisible logic that promises to resolve every loose end.

But should all mysteries be explained? In the introduction to volume two of his book Poetics of Cinema, Ruiz writes: “In today’s cinema (and in today’s world) there is too much light. It is time to return to the shadows.” Mysteries of Lisbon casts more than its share. Though it’s adapted from an 1854 novel by Camilo Castelo Branco, and often seems slavishly faithful to the expansive scope of 19th-century fiction, Ruiz also subverts the basic thrust of such stories. Often pegged as a surrealist, he was interested in the ability of cinema—and all fiction—to create paradoxes and disbelief.

For example, Ruiz’s breakthrough film, The Hypothesis of the Stolen Painting (1978), presents itself as a commentary on several fictional artworks, but it soon turns into a detective story, each canvas revealing clues that promise the solution to some greater mystery. The pattern formed by the paintings, however, is unsolvable and in fact may not exist at all; possibility and doubt go hand-in-hand. Similarly, each tidy solution offered in Mysteries of Lisbon seems more arbitrary and senseless than the last. This turns into something of a running gag: the marriage of Alberto de Magalhães to the former mistress of João’s mother’s husband is explained away as “one of those coincidences no novelist could invent.”

Despite this frequently wry, self-conscious tone, Mysteries of Lisbon has an underlying sadness. Ruiz was diagnosed with liver cancer while making the film (he would ultimately overcome the disease with the help of a liver transplant, only to die unexpectedly of a lung infection), and Mysteries feels sometimes like a summary of his life’s work and other times like a contemplation of mortality. Death-bed scenes abound. Everyone has alter egos (“I’ve been other men,” Father Dinis confesses at one point) whose actions they must come to terms with before the end. What emerges is a vision of human beings as self-imagined, mercurial constructs fated for oblivion (a notion summed up by the title of one of Ruiz’s best-known films—Three Lives and Only One Death).

Though Mysteries of Lisbon closes with a blinding flash of light, its ending is even more shadowy and mysterious than its beginning. The adult João (played by Afonso Pimentel) eventually discovers that the events and circumstances of his life are merely the product of other people’s intrigues, unrequited loves, and vendettas. Having found himself in a terrifyingly orderly world where everything is related and all mysteries have been solved, he realizes that he has no reason to exist. “My life no longer made any sense,” João deadpans at the end; if it were real, the neatness of fiction would drive a man to despair.

This is about as close to a thesis as Ruiz ever gets, but by his own admission, he didn’t like to make things simple. That isn’t to say that Mysteries of Lisbon is a “difficult” movie—in fact, it’s energetic and fun—but that it evades easy definition. Like the patterns in The Hypothesis of the Stolen Painting, the world of Mysteries of Lisbon represents a closed system for only so long. In a finale that’s uncharacteristically sincere for a Ruiz film, the adult João travels around the world, unable to escape the tidiness of his life, followed at every turn by contrivances; arriving at an inn on the other side of the globe, he checks into a room that looks identical to his childhood bedroom at the boarding school. These last few minutes of the film upend the four-and-a-half hours that preceded them; the final sequence could be seen as self-sabotage on Ruiz’s part or as a coup de grace for the central character. Either way, this cautionary tale about the dangers of trying to solve every mystery ends with one that’s truly unsolvable.