Farhan Qureshi(R Madhavan) and Raju Rastogi(Sharman Joshi) are students at the prestigious Imperial College of Engineering (ICE). Farhan’s passion is wildlife photography, but he pursues an engineering degree to appease his father. Raju chooses engineering with hopes of improving his family’s financial situation, but his lack of self-confidence results in poor grades. Their third roommate and friend, Ranchodas “Rancho” Chanchad (Aamir Khan), has an immense interest in engineering, and invents in his spare time. After giving unorthodox answers in class, Rancho faces scrutiny from the college’s director, Viru Sahastrabuddhe (Boman Irani), known as “Virus”, whose traditional philosophies on education and learning contrast sharply with Rancho’s atypical ideas of teaching. Virus is shown to be extremely strict — a trait that indirectly caused his own son’s suicide after putting him under excessive pressure.
Rancho eventually falls in love with Pia (Kareena Kapoor), Virus’ younger daughter, who is a medical student in residency at the city’s hospital. Rancho always scores the highest marks on exams out of his class, much to the dismay of both Virus and Chatur Ramalingam (Omi Vaidya), an arrogant student who believes in rote learning, and dislikes Rancho, Farhan, and Raju. One night, Rancho, Farhan, and Raju drunkenly break into the Sahastrabuddhe household to allow Rancho to profess his love to Pia. After discovering their antics, Virus threatens to expel Raju unless he writes a letter blaming Rancho for the break-in. Unwilling to betray Rancho or disappoint his family, Raju unsuccessfully attempts suicide, and ends up in a coma. After intensive care and support from his friends, Raju recovers just before he successfully interviews for a corporate job. Before this Rancho and Pia post Farhan’s letter to his favorite photographer. Farhan gets a positive response but fears his father. Rancho then convinces him to go confront his father and his father reluctantly agrees to it. All this while Virus gets frustrated at Rancho’s influence on Raju and Farhan, and he conspires to deliberately modify the final exams and make it so difficult so that none of them can graduate. However, Pia gives Virus’ office duplicate keys to Rancho to enable him to get the exam papers. But Virus finds them and expels Rancho. The trio, however, earn a reprieve when Virus’ pregnant elder daughter Mona (Mona Singh) goes into labour at the same time a heavy storm cuts off all power and traffic. Despite this, Rancho uses his engineering knowledge to deliver the baby in the college common room. A grateful Virus finally acknowledges Rancho as an extraordinary student, and allows the three to graduate. Rancho then unexpectedly disappears shortly after the ceremony. None of them have heard from Rancho since graduation.
10 years later, Farhan is a successful wildlife photographer, Raju is doing corporate job and settled in a comfortable lifestyle with his wife and Chatur Ramalingam is a vice president of a corporation in the USA. In present day Farhan is boarding for a flight. Suddenly he gets a call from Chatur telling him that he found Rancho. Farhan lands the flight by acting that he is dead. On the way to the campus he takes Raju and reaches the campus only to find Chatur but no Rancho. But Chatur reveals that Rancho is in Shimla. So, the three of them go to Shimla. But at Shimla they discover that the Rancho they knew was actually “Chhote”, an orphaned servant to the Chanchad family household in Shimla. When the real Ranchodas (Javed Jaffrey) went to London for four years, his father allowed the servant to fill his son’s place – including using his son’s full name – and take credits for the degree. Ranchodas gives address and informs that Chhote currently lives in Ladakh, where he is a school teacher. On the way, the three rescue Pia from her arranged wedding with Suhas Tandon (Olivier Sanjay Lafont) at Manali so that Pia could marry “Rancho”. Upon arrival in Ladakh, the four find the village school where they see young students’ inventions resembling Rancho’s own college projects. Raju, Farhan, and Pia then happily reunite with Rancho on a sandbar, where Rancho and Pia kiss. Assuming Rancho to just be a school teacher, Chatur forces him to concede that he is less successful than Chatur. Shortly after, Rancho reveals that he became a scientist (while also teaching young children when he’s not researching), and that his real name is Phunsukh Wangdu. Much to Chatur’s horror, this also happens to be the name of an important inventor that Chatur had spent a year trying to find and sign a business deal with.