Farhan Qureshi (R. Madhavan), Raju Rastogi (Sharman Joshi), and Rancchoddas Shamaldas Chanchad "Rancho" (Aamir Khan) are three engineering students who share a room in a hostel at the 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 raise his family's fortunes while Rancho, driven by his passion for machines and devices, studies for joy of it. However, due to this different approach Rancho incurs the wrath of dean of college, Professor Viru "Virus" Shahastrabuddhe (Boman Irani). Virus labels Rancho and his friends as "idiots" and attempts on a number of occasions to break up Rancho's friendship with Farhan and Raju. In contrast, Virus' favorite student, Chatur "Silencer" Ramalingam, (Omi Vaidya) believes in mindless memorizing over understanding, in order to reach his goals of corporate and social status. Meanwhile, Rancho also falls in love with Virus' medical student daughter Pia (Kareena Kapoor) when he, Raju and Farhan crash her sister's wedding banquet in order to get a free meal, in the process further infuriating Virus.
Things further escalate when the three friends, who are already drunk, break into Virus' house at night to allow Rancho to propose to Pia, and then urinate on a door inside the compound before running away. The next day, Virus threatens to expel Raju unless he squeals on Rancho. Not wanting to betray his friend or let down his family, Raju jumps out of the third floor window and ends up in a coma. Following his recovery, Raju takes an unexpected approach for an interview for a corporate job whilst Farhan decides to pursue his love of photography. The two friends succeed with their tasks and this further enfuriates Virus, causing him to come up with a plan that will jeopardize Raju's job. During this process, Pia overhears this and decides to help Rancho and Farhan by providing them with the keys to her father's office. However, Virus catches them and expels them on the spot. After that Pia angrily confronts him, revealing that his son, Pia's brother, committed suicide when he could not get into ICE, like Virus wanted him to. At the same time Viru's pregnant elder daughter Mona (Mona Singh) goes into labour. A heavy storm cuts all power and traffic, and Pia is in self-imposed exile because of her revealing of her brother's actions. She instructs Rancho to deliver the baby in the college common room via VOIP. After the baby is apparently stillborn, Rancho resuscitates the baby. Virus reconciles with Rancho and his friends, and allows the trio to stay for their final exams.
Their story is framed as intermittent flashbacks from the present day, ten years after Chatur promised to become more successful than Rancho. Having lost contact with Rancho, who disappeared during the graduation party and went into seclusion, Raju and Farhan begin a journey to find him. They are joined by Chatur, now a wealthy and successful businessman, who joins them, brazenly confident that he has surpassed Rancho and also looking to seal a deal with a famous scientist and prospective business associate named Phunsukh Wangdu. When they find Rancho's house in Shimla, they find a completely different Rancho (Jaaved Jaffrey). From him they come to know that their friend was a destitute servant boy "Chhote" who loved learning, while he, the real Rancho, disliked study. The family agreed to let the servant boy study in Rancho's place instead of labouring. In return, the real Rancho would pocket the qualifications and after graduating, the servant boy will cease all contact. The real Rancho reveals that Chhote is now a school-teacher in Ladakh.
Raju and Farhan find Pia and arrive in Rancho’s school. Pia and the fake Rancho rekindle their love, while Chatur mocks Rancho for becoming a school teacher. He asks Rancho to sign on a "Declaration of defeat" document. When Rancho's friends ask for his real name is, he reveals that he is actually Phunsukh Wangdu himself. Chatur finds out about this and is horrified; he accepts his defeat and pleads his case with Phunsukh to establish the business relationship he was after.