The emotionally withdrawn Joel Barish and the unrestrained free-spirit Clementine Kruczynski begin a relationship on a Long Island Rail Road train from Montauk, New York. They are almost immediately drawn to each other despite their radically different personalities.
Although they do not realize it at the time, Joel and Clementine are, in fact, former lovers, now separated after having spent two years together. After a fight, Clementine hires the New York City firm Lacuna, Inc. to erase all of her memories of their relationship. Upon discovering this, Joel is devastated and decides to undergo the procedure himself, a process that takes place while he sleeps.
Much of the film takes place in Joel's mind. As his memories are erased, he tries to evade the erasing effects of the procedure by hiding Clementine in remote parts of his unconscious. Joel finds himself revisiting them in reverse. Upon seeing happier times of love with Clementine from earlier in their relationship, he struggles to preserve at least some memory of her and his love for her. Despite his efforts, the memories are slowly erased, with the last memory of Clementine telling him, "Meet me in Montauk."
In separate but related story arcs occurring during Joel's memory erasure, the employees of Lacuna are revealed to be more than peripheral characters. Patrick, one of the Lacuna technicians performing the erasure, is dating Clementine while viewing Joel's memories, and copying aspects of their relationship in order to seduce her. Mary, the Lacuna receptionist, is dating the other memory-erasing technician, Stan. As it turns out, Mary had an affair with Dr. Howard Mierzwiak, the married doctor who heads the company—a relationship which she agreed to have erased from her memory when it was discovered by his wife. Once Mary learns this, she quits her job, confronts Stan about his knowledge of her relationship with Howard (which he denies knowing about), steals the company's records, and sends them out to all the company's clients.
Joel and Clementine come upon their Lacuna records shortly after re-encountering each other on the train. They react with shock and bewilderment, given that they have no clear memory of having known each other, let alone having had a relationship and having had their memories erased. Joel beckons Clementine to start over; Clementine initially resists, pointing out it could go the same way. Joel accepts this, and they decide to attempt a relationship anyway, starting their life together anew.