The movie follows a man's search for perfection in a world where life rarely measures up to the idealized images that constantly bombard us.
Gary Shaller (Freeman), who gained commercial success in the past as the keyboard player in the band "On the One", is in a failing relationship with Dora (Gwyneth Paltrow), and working for his former bandmate Paul (Simon Pegg), writing and recording commercial jingles. Gary is having lucid dreams about a woman named Anna (Penélope Cruz), with whom he is deeply infatuated. He learns more about lucid dreaming by buying books and attending classes taught by lucid-dreaming guru, Mel (Danny DeVito).
Gary eventually discovers that the girl he dreams about does, in fact, exist. Paul arranges for Gary to meet her, but this proves disappointing, as she fails to live up to the expectations that Gary has built up in his dreams of her. He eventually continues to dream about her, even soundproofs his apartment, and makes other efforts to be able to sleep longer, so that he can remain with Anna for longer periods of time.
Eventually, feeling as though he is betraying Dora, he attempts to go back to her. While crossing the street to reach her, he is hit by a car. As the movie ends, he is fully immersed in his dream world, apparently while being in a coma in a hospital.