The film opens with Sunita (Jiah Khan), a medical student, and her friends working on a project about the human brain. She wants to investigate the curious case of Sanjay Singhania (Aamir Khan), a (former) notable city businessman, who is reported to have anterograde amnesia. Her professor denies access to Sanjay's records as it is currently under criminal investigation. Sunita, nonetheless, decides to investigate the matter herself.
Sanjay is introduced as he brutally murders a man. He takes a Polaroid picture of the man, and writes on it done. It is revealed that Sanjay has anterograde amnesia where he loses his memory every 15 minutes. Sanjay uses a system of photographs, notes, and tattoos on his body to recover his memory after each cycle. It is revealed that Sanjay is ultimately out to avenge the death of his sweetheart Kalpana (Asin), and that he is systematically killing the people who were responsible for it. His main target is Ghajini (Pradeep Rawat), a notable social personality in the city.
Police Inspector Arjun Yadav, on the case of the serial murders, tracks Sanjay down to his flat and attacks and disables him. Yadav finds two diaries where Sanjay has chronicled the events of 2005 and 2006. The film flashes back to 2005 as Yadav reads the diary. Sanjay Singhania is shown as the owner of the Air Voice mobile telephone company. In the course of his business, Sanjay sends his men to meet Kalpana, a struggling model, about putting up a billboard above her apartment. The owner of Kalpana's advertising firm misinterprets this as a romantic advance, and in view of a possible lucrative Air Voice ad campaign and other benefits, encourages Kalpana to accept the overture. Kalpana thinks of this as an innocent prank that may fetch her better modeling work, and decides to play out the charade as Sanjay's girlfriend. As soon as Sanjay knows of this matter, he decides to confront Kalpana but falls in love with her on first sight. Thus, he introduces himself as Sachin. Eventually both of them hang around together and gradually develop a liking towards each other. The diary ends with Sanjay proposing to Kalpana and promising himself that he will reveal himself as Sanjay Singhania if she accepts.
When Yadav is about to read the 2006 diary, Sanjay returns to senses, attacks him and ties him up. He tracks down Ghajini to a college function where Ghajini is the guest of honor. Sanjay took pictures of Ghajini and decides to kill him. He meets Sunita at the function who, after some conversation, decides to befriend him. Later that evening, Sanjay mistakenly attacks and kills one of Ghajini's goons in the parking lot. Ghajini is perplexed and fails to recollect the incident. However he decides to find and kill his enemies one by one, but Sanjay is not among them.
In the meantime, Sunita visits Sanjay's flat and finds Yadav, beaten and bound. Sunita finds the two diaries and frees Yadav. She also finds that Ghajini is Sanjay's target. Yadav tells her that Sanjay is a known serial murderer. Sanjay arrives suddenly; he remembers neither of them and chases them out. Yadav is eventually hit by a bus, while Sunita barely escapes, going into a boutique. Believing Ghajini is in danger, she informs him that Sanjay is after him. Ghajini arrives at Sanjay's flat to kill him. He destroys all the photographs, notes and scratches off Sanjay's tattoos. Satisfied that he has neutralized Sanjay by wiping out any trace that connects back to him, Ghajini leaves.
Meanwhile, back in her dorm, Sunita reads the diaries. The film flashes fast to 2005 then back to 2006. It is revealed that Kalpana had accepted Sanjay's proposal. This diary ends abruptly. Sunita investigates further, and discovers that Kalpana was traveling to Goa for a modeling assignment by train when she came upon 25 innocent young girls being trafficked to Goa. She saves the girls who name Ghajini as the ringleader of the racket. Ghajini kills two girls, who recognized him, and goes in search of Kalpana. His goons break into her apartment and wait for her to return. Sanjay arrives there to meet Kalpana. Her last word to him was Ghajini. The goons attack Kalpana. Sanjay intervenes but Ghajini hits him over the head with an iron rod. Sanjay's last vision was to witness Ghajini brutally murder Kalpana with the iron rod.
Sunita, now aware of the shocking truth, finds Sanjay in the hospital and tells him the truth. He flies into a rage and he told her to lead him to Ghajini. Arriving at Ghajini's lair in downtown Mumbai, Sanjay confronts all of Ghajini's henchmen and with superior strength, manages to disable. Finding Ghajini himself, Sanjay fights Ghajini hand-to-hand. However, Ghajini realizes that he is no match for Sanjay's strength, so the two engage in a chase until Sanjay's memory loss strikes again. Ghajini turns around and stabs him. He begins to taunt the stabbed Sanjay with the grisly tale of how he murdered Kalpana, when Sanjay, with a sudden burst of last minute strength, overpowers Ghajini. Sanjay kills Ghajini in the same way as Ghajini had killed Kalpana.
The film ends with Sanjay, still experiencing amnesia, volunteering at an orphanage. Sunita gives him a gift which is the cement slab on which Kalpana and Sanjay impressioned their first footprints when the couple moved into a new apartment to remind him of his fond association with Kalpana.