Joel Barish (Jim Carrey) wakes up alone and confused on Valentine's Day. He waits on the platform, dressed for work. Suddenly, something comes over him and he runs to the opposite platform, boarding a different train that is destined for Montauk. His voiceover informs the audience that he is not usually impulsive. He sits on the cold, snowy beach in Montauk and pulls out his journal, which has a number of pages ripped out. He hasn't written in it for two years.
Walking along the beach, Joel notices a woman with blue hair in a bright orange sweatshirt, and wonders why he can't meet women. The same woman happens to be on the same train as Joel and finally says hello. They have a conversation - her name is Clementine (Kate Winslet), and she is erratic and opinionated. She encroaches on Joel's personal space, making him uncomfortable. There is something he likes about her, though, because when she invites him up to her apartment, he goes. The next day, he accompanies her on a nighttime trip to walk on the frozen Charles River. There is something brewing between them.
Cut to Joel in his car, bawling. It is unclear when or how this happened. Distraught Joel drives through the rainy streets and goes back to his apartment, while a white van follows him. After Joel is asleep, two men (Patrick and Stan) unload the white van and bring a collection of strange equipment into Joel's apartment. Inside Joel's mind, he remembers telling his friends Rob and Carrie about his attempt to make up with Clementine. He went to see Clementine, but she was with a new guy and pretended not to know who Joel was. Rob and Carrie reluctantly show Joel a card they received in the mail from Lacuna Inc, telling them that Clementine has had Joel erased from her memory. Joel is angry and upset, and barges into Dr. Mierzwiak's office at Lacuna, demanding to have the procedure himself.
Dr. Mierzwiak asks Joel to bring in all the items that remind him of Clementine, which he and Stan use to create a map of Clementine in Joel's mind. We now understand that Stan and Patrick are in Joel's apartment to erase Clementine from his memory. They start by deleting the most recent memories that reveal the bitterness of their breakup. Meanwhile, though he is asleep, Joel is lucid enough to hear Patrick tell Stan that he has been using Joel's things to woo Clementine. Joel realizes that Clementine was kissing Patrick when he had gone to see her earlier.
While the memory erasure is going on, Mary Svevo (Dr. Mierzwiak's receptionist) comes over to hang out with Stan while he is working. They get drunk and high while Patrick decides to go see Clementine. Patrick finds Clementine upset and disturbed. She insists that they go to the Charles River immediately, and Patrick gives her a gift - the gift that Joel purchased for her and relinquished to Lacuna when he decided to have Clementine erased.
Meanwhile, in Joel's mind, most of the more recent bad memories are gone and he's now watching the happy, tender moments with Clementine fade away. He realizes that he no longer wants to lose his memories and begs Mierzwiak to let him keep them - but Stan and Mary cannot hear him. Joel grabs Clementine's hand and they try to outrun the procedure. Clementine suggests that he hide her in memories where she didn't previously exist, so Joel takes her into his childhood memories. He leads her deeper and deeper into his consciousness, trying to duck underneath his most humiliating moments, but it doesn't work.
Meanwhile, Mary and Stan have had sex and are cavorting around Joel's apartment when Stan notices that the machines have stopped erasing Joel's memory. He panics and calls Dr. Mierzwiak. Mary swoons all over Dr. Mierzwiak when he arrives, but he gets straight to work, chasing down Joel and eradicating the memories he is trying to hide within. Stan goes for a walk, and while he is gone, Mary kisses Dr. Mierzwiak. Mrs. Mierzwiak drives up at that moment and witnesses the coupling. Dr. Mierzwiak tries to explain the situation to his wife, and Mary insists that she was the instigator. Mrs. Mierzwiak, however, is not moved - and tells Mary that she and Dr. Mierzwiak have already had an affair. Mary is shocked - Dr. Mierzwiak tells her that they did have an affair and Mary begged to have the procedure done so she could "move on."
Joel, still unconscious, is now experiencing the memories of his first meetings with Clementine. They met during a beach party in Montauk, and Clementine wanted him to break into a house with her. However, when this actually happened, Joel succumbed to his fear and left her behind. Knowing that this memory is their last, Clementine begs him to stay this time. As the memory fades away, Clementine whispers, "meet me in Montauk." Meanwhile, Mary breaks into the Lacuna offices and hears her voice on tape asking to have Dr. Mierzwiak erased from her memory. Back in Joel's apartment, Dr. Mierzwiak finishes the procedure, and he and Stan leave.
Cut to the opening scene, where Joel wakes up. Now, the audience knows that Joel and Clementine have already gone through a doomed love affair and are meeting in Montauk for the second time without knowing it. Mary Svevo quits her job, and steals all of the files and tapes from the Lacuna office. When Joel and Clementine return from the Charles River for the second time (after meeting on the train from Montauk), Joel stops at her house so she can pick up her toothbrush. She also grabs her mail, and finds the tape and file that Mary has sent. She puts the tape in the tape player in Joel's car and they both hear Clementine's voice insulting Joel and explaining why she wants to break up with him. Joel thinks it's a joke and kicks her out of his car.
Later, Clementine comes to Joel's apartment, only to find him listening to his own tape. It's awkward between them, and Clementine finally leaves. This time, Joel chases her and asks her to stay. They ponder what to do - they like each other now but they know how their love story ends. Eternal Sunshine of the Spotless Mind finishes with this open-ended moment, followed by a surreal-looking scene where Joel and Clementine frolic on a snowy beach in Montauk.