Raju Rastogi(Sharman Joshi) are students at the prestigious Imperial College of Engineering(ICE). Farhans passion is wildlife photography, but he pursues an engineering degree to appease his father. Raju chooses engineering with hopes of improving his familys financial situation, but his lack of self-confidence results in poor grades.heir third roommate and friend, RanchodasRancho Shamaldas Chanchad(Aamir Khan), has immense interest in robotics, and invents in his spare time. After giving unorthodox answers in class, Rancho faces scrutiny from the colleges director, Dr. Viru Sahastrabuddhe(Boman Irani), known as "Virus", whose traditional philosophies on education and learning contrast sharply with Ranchos atypical ideas of teaching. Virus is shown to be extremely strict — a trait that indirectly caused his own sons suicide by 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 citys hospital. He also regularly scores the highest on exams out of his class, much to the dismay of both Virus and Chatur, an arrogant Tamil student who also despises Rancho. One night, Rancho, Farhan, and Raju drunkenly break into the Sahastrabuddhi 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.
Farhan has adopted Ranchos outlook and decides to pursue his love of photography. Frustrated at Ranchos influence on Raju and Farhan, Virus conspires to deliberately modify the final exams so that none of them can graduate. The trio, however, earn a reprieve when Virus pregnant elder daughter Mona(Mona Singh) goes into labour at the same time that 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.
Ten years later, Chatur is the vice president of a corporation in the United States, Farhan is a successful photographer, and Raju is married while living a comfortable lifestyle. None of them have heard from Rancho since graduation, and the three reunite at the college campus water tower to find him. 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 sons place - including using his sons full name - and take credits for the degree. With the help of the real Ranchodas, the trio travel to a village school in Ladakh, where Rancho supposedly works as a teacher. On the way there, the three rescue Pia from her arranged wedding at Manali.
Upon arrival in Ladakh, the four find the village school where they see young students inventions resembling Ranchos 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 hes not researching), and that his real name is Phunsukh Wangdu. Much to Chaturs horror, this also happens to be the name of a wealthy client that Chatur had spent a year trying to find and sign a business deal with.