Farhan Qureshi (R. Madhavan), Raju Rastogi (Sharman Joshi) and Ranchhoddas "Rancho" Shamaldas Chhanchad (Aamir Khan) are three engineering students who share a room in the residence of Imperial College of Engineering (ICE).
Farhan is studying engineering to pursue his father's wishes over his own wish — to become a wildlife photographer. Raju is studying to get his family out of poverty. On the other hand, Rancho studies for his simple passion in machines. Rancho believes that that one should follow excellence, not success, as success will itself if excellence is followed.However, this different approach is sneered upon by the dean of the college, Professor Viru "Virus" Sahastrabudhhe (Boman Irani).
Virus's favorite student, Chatur "Silencer" Ramalingam (Omi Vaidya), believes in mindless memorizing over understanding in order to reach his goals of corporate status. Rancho falls in love with Virus's daughter Pia (Kareena Kapoor), a medical student. Angered, Virus continually attempts to break Rancho's friendship with Farhan and Raju. Things further escalate when the three friends drunkenly break into Virus's house one night.The next day, Virus threatens to rusticate Raju unless he squeals on Rancho.
Not wanting to betray his friend or let down his family, Raju attempts suicide and ends up in a coma. With two months of extensive care from his mother, Rancho, Farhan, and Pia, he makes a full recovery and thus discards his fear of the future. His frankness impresses the corporate agents during a job interview and they hire him. Farhan, goaded by his friends, convinces his parents to allow him to drop out of school and follow his wildlife photographer dream.
Virus schemes to set Raju an impossibly tough final exam, as the job offer is contingent on graduation. Pia learns of this and informs Rancho and Farhan, who break into Virus's office for the exam. Virus catches them and expels them on the spot. Pia angrily confronts him, revealing that her brother, whom their father had pushed to become an engineer despite his preference for literature, committed suicide after failing ICE's entrance exam three times. Pia then flees to her hospital.Later that night, Pia's pregnant older sister Mona (Mona Singh) goes into labor.
A heavy rainstorm cuts all power and floods the streets, making it impossible for an ambulance – or Pia – to reach Mona. The students rig up a power supply and other equipment so that, with guidance from Pia by webcam, they can deliver the baby. The baby is apparently stillborn, but kicks when the students all chant Rancho's calming mantra "All is well. " The baby recovers and Virus is thus obliged to forgive Rancho and his friends, allowing them to stay for their final exams.Their story is framed as intermittent flashbacks from the present day, ten years after Chatur bet that he'd become more successful than Rancho.
Chatur, who now boasts of his wealth and his bright career with an American company, is eager to rub Rancho's nose in it. Raju and Farhan have tried to find Rancho for five years with no results; with Chatur's help, they travel to the Chhanchad estate inShimla, where they find a completely different man: the real Ranchhoddas Chanchad (Jaaved Jaffrey).They coerce the stranger into revealing the truth: their friend was an orphaned servant boy who loved learning, unlike the real Rancho. After seeing the boy's intelligence, Rancho's father arranged for the servant boy to go to college and earn a degree in Rancho's name.
The real Rancho reveals that their friend is now a schoolteacher in Ladakh. On the way, the three rescue Pia from an unhappy wedding, over Chatur's objections: he wants to get the trip finished quickly, because he is in a hurry to seal a business deal with Phunsukh Wangdu, a renowned scientist.In Ladakh, Raju and Farhan find villagers working with gadgets that show the stamp of Rancho's ingenuity, and learn that Rancho has all of Farhan's photography books and reads Raju's blog every day. The three friends reunite and Pia and Rancho rekindle their love, while Chatur mocks Rancho.
However, Rancho reveals his true name: Phunsukh Wangdu. Chatur, mortified, accepts his defeat and pleads with Phunsukh to forgive him and accept his company's contract. Phunsukh, Pia, Farhan and Raju run laughing into the distance with Chatur in pursuit.