David Aames (Tom Cruise) drives to work, he finds the streets of New York strangely deserted at rush hour. With growing unease he drives to Times Square and finds the entire city abandoned. He then awakens in his bedroom once again to realize he's only been having a vivid dream.
Cut to: David in a jail cell describing a dream to Dr. Curtis McCabe (Kurt Russell), a psychologist who has been assigned to him. David has been charged with a murder he cannot remember, and he wears a mysterious pale mask. He and Dr. McCabe discuss the events that led to his eventual incarceration. Following the death of David's father, he was given 51% ownership of his father's publishing company. The rest of the company is owned by a board of directors that David disparagingly calls the "Seven Dwarfs." Each of them believed that he was next in line to take over the company after David's father died. David can have anything his heart desires, and nothing is beyond him.
On the night of his birthday party which also includes a conversation with a drunken Thomas Tipp (Timothy Spall), the company attorney and an old friend of David's father, David considered firing Thomas for what he believes is his incompetence as an attorney, but he has a change of heart when Thomas makes a sad confession.
David's best friend, Brian Shelby (Jason Lee), brings with him a girl named Sofia Serrano (Penelope Cruz) whom he just met at the library. Almost instantly, David and Sofia flirt with each other, almost completely ignoring Brian. However, Julianna Gianni (Cameron Diaz), a regular bed partner for whom David has no deep feelings, crashes his party. She stays distant but keeps a close eye on him the entire night. Once David realizes Julianna is there, he asks Sofia to pretend to engage in a deep conversation with him so that Julianna won't come near him. David and Sofia end up hitting it off. David walks Sofia back to her place, where they stay up all night talking.
The next morning as David is getting ready to drive to work, Julianna drives up beside him asking how his night with Sofia was. Julianna makes David feel guilty about ignoring her and convinces him to get into her car. It quickly becomes apparent that she is obsessed with David. She starts driving recklessly, speeding through busy city streets, all the while insisting that she's deeply in love with him and berating him for treating her so casually. Fearing for their safety, he tries to get her to stop the car by telling her that he loves her. She drives the car off a bridge in an attempt to kill them both.
Julianna did not survive the crash. David did, however, although his face and right arm are mangled, and he suffers blinding headaches due to the metal pieces holding his skull together. He spends a long time in isolation before deciding to take back control of his company and see Sofia again. She appears hesitant to be around him, and when they go on a date she brings Brian along. The date is a disaster as David drinks too much and makes Sofia increasingly uneasy around him. The three part ways at the end of the night, and David ends up passing out on a sidewalk. It is morning when Sofia wakes him up at that same exact spot and tells him that she will stay with him if he can get his act together. From that moment on, David's life is turned around. His team of plastic surgeons is able to restore his face and he finds his soul mate in Sofia.
David's new-found happiness is short-lived, however, when he begins hallucinating. He looks in the mirror to see his face once again disfigured. A mysterious man (Noah Taylor) turns up wherever he goes and tells David that he has the power to control the world. And one night he goes to bed with Sofia and wakes up to find himself with Julianna, who insists she really is Sofia. He grows violent, convinced that Julianna is alive and playing games with him. He is arrested and told by Tipp that he severely beat Sofia, but Tipp will have the case thrown out. Tipp shows David photos of Julianna with a bruised face, but everybody, including his best friend Brian, tells him that it was Sofia he attacked.
David breaks into Sofia's apartment and finds that every photo he'd seen of Sofia is now of Julianna. Julianna attacks him thinking he's an intruder but then apologizes while still insisting she is Sofia. She leaves the room and the actual Sofia returns in her place as if nothing unusual had happened. They begin to make love but while they are in the middle of the act he finds that he is making love to Julianna. In a fit of panic he suffocates her and then discovers he has just killed Sofia.
When David is finished telling Dr. McCabe his story he still can't bring himself to believe that he killed anybody. Dr. McCabe, frustrated by David's failure to tell him anything meaningful that might help his case, tells him that he can no longer help David and will try to argue for "temporary derangement". This odd turn of legalistic phrase is just one of many clues that in this version of David's world all is not what it seems. As Dr. McCabe leaves, David sees an infomercial for a cryonics company called "Life Extension." This infomercial involving a dog that has been frozen and brought back to life has appeared at several points throughout the film. David is entranced by the commercial, and McCabe sees that there may be a connection between Life Extension and David's amnesia.
Escorted by Dr. McCabe and the police, David visits Life Extension and realizes that he had signed on as a client. He had opted for an extra feature called the Lucid Dream. This allows cryogenically-frozen, clinically dead clients to experience an unending custom-made dream life with no memory of their physical death.
David realizes that he is now living in the Lucid Dream and that the mysterious man is his "Technical Support." The Support Technician explains that the Lucid Dream was "spliced" into his memories at the point where he passed out on the sidewalk after his night out with Sofia and Brian. But the dream went awry and turned into a nightmare. Since nothing he experienced after the splice was real David realizes that he never murdered anybody. Dr. McCabe tells him that the guilt he felt for the way he treated Julianna may have caused his subconscious to merge Julianna and Sofia. But it turns out that Dr. McCabe isn't real either; he's just a character David created in his dream to be the father figure he always wanted. Most curious is the fact that Dr. McCabe seems to believe that he himself is real and only reluctantly comes to accept the truth (he had previously mentioned that he was going out with his two daughters for dinner after a session with David, but when The Support Technician asks him "What are their [your daughters'] names, Dr. McCabe has no response). Tech Support tells David that in reality, he never saw Sofia again, and that Thomas Tipp, the attorney that David considered firing in the beginning, had saved the company for David and helped him regain control from the board of directors. But David, suffering constant pain and depression following his disfigurement, committed suicide.
In the end, technical support reveals an upgrade to the software which allows David to either be reinserted into the lucid dream with no memory of the nightmare portion or to be awakened in the present time (which is 150 years after he was frozen) and live in the real world with a restored body. David chooses to be awakened in this future present realizing that everyone he ever knew will be long dead and his wealth will be worth far less. After one last lucid-dream rooftop exchange with Sofia in which she vows to "find you again" he leaps off the skyscraper. Multiple memory-images cascade frenetically through his mind as he falls. The final shot is of a brief whiteout (rather than the blackout) accompanied by the sound of a woman's voice telling him to "open your eyes" and an extreme closeup of a single human eye opening and staring into the camera.