Farhan and Raju are called at ICE by Chatur on "Sept.5" . Then Farhan tells the story of Rancho in flashbacks of 10 years ago. Farhan Qureshi (R. Madhavan) and Raju Rastogi (Sharman Joshi) begin their college year in the prestigious Imperial College of Engineering (ICE) in Delhi. They are joined by Ranchoddas Chanchad (Aamir Khan), nicknamed "Rancho", as their roommate. While Farhan chose to pursue engineering over his passion for photography to appease his father, Raju has taken the course in an attempt to end his family's poverty. Rancho, on the other hand, is genuinely interested in science and engineering. He believes in hands-on learning and tends to give unorthodox answers in class, resulting in him coming into conflict with the professors, particularly the institution's director, Viru Sahastrabuddhe (Boman Irani), whom the ICE community nicknames "Virus". Virus's traditional and strict philosophies on education contrast sharply with Rancho's carefree love of learning. Meanwhile, Chatur (Omi Vaidya), nicknamed “Silencer", is an arrogant Ugandan Tamil student with little knowledge of Hindi, who is obsessed with topping the exams.
Sometime later, the trio finds that a student named Joy Lobo (Ali Fazal) committed suicide by hanging himself; his suicide was caused by depression after Virus informs Joy's father that he'll be unable to graduate due to the delay in his submission of an assignment. Joy had taken longer as he wanted to perfect his breakthrough drone design of a quad-copter. Rancho criticizes Virus' method of teaching and tries to show him how much pressure engineers face when they study, angering him further. Rancho visits his friends' families and later the trio then gatecrash a wedding to eat good food. They meet and befriend Pia (Kareena Kapoor), who turns out to be Virus' daughter and a residency student at the city's hospital. When Virus spots the trio, he summons Farhan and Raju on the next working day and threatens them of consequences of being friends with Rancho by comparing their family's income. He tells them that Rancho comes from a very rich family and does not need to worry about getting good grades and making a career. Affected, Raju moves out to Chatur's room. During the Teachers Day celebration, Chatur is humiliated when he delivers a Hindi speech modified by Rancho and as a result, he bets Rancho that ten years later they would see who is more successful. Sometime later, Rancho saves Raju's dying father with the help of Pia. Raju reconciles with his friends while Pia falls in love with Rancho.
One night during their senior year, the three friends drunkenly break into the Sahastrabuddhe residence so that Rancho can propose to Pia. As the trio escape, Virus recognizes Raju and threatens to expel him unless he writes a letter implicating Rancho for the break-in. Unwilling to betray Rancho or disappoint his family, Raju unsuccessfully attempts suicide and ends up in a coma. With intensive care and support from his friends, Raju recovers just in time for a corporate job interview. Meanwhile, Rancho and Pia post Farhan's letter to his favourite photographer Andre Istvan, who offers him a position as an assistant. After advice from Rancho, he communicates his dream to his father, who though reluctant at first, gives his blessings for the sake of his son's happiness. Raju also succeeds in getting a corporate job.
Infuriated by Rancho's influence, Virus sets a difficult final exam to fail Raju to which Pia tries to help the trio by revealing to them the location of the exam paper; unfortunately, Virus finds out and expels them. Pia confronts Virus about her brother who also committed suicide because he couldn't meet Virus' expectation of clearing the engineering exam. That same night, Virus' pregnant elder daughter Mona goes into labour during a heavy storm that cuts off all traffic and electricity. Rancho and the other students use their engineering knowledge to quickly modify a vacuum cleaner into a ventouse and deliver the baby with the help of Pia over a video call. A grateful Virus finally acknowledges Rancho as an extraordinary student and revokes their expulsion. On graduation day, Rancho suddenly disappears shortly after the ceremony ends.
Five years later, Farhan is a successful wildlife photographer while Raju is married and settled with his family in a comfortable lifestyle with a corporate job and Chatur is the vice president of a reputable corporation in the United States; neither the three of them have heard from Rancho since graduation. Arriving at Shimla, where Rancho was spotted in the background of a snapshot, they meet a man who turns out to be the real Ranchoddas Chanchad (Javed Jaffrey). From him, they learn that the Rancho they knew was actually "Chhote", an orphaned servant to the Chanchad family. Ranchoddas' father arranged for Chhote to attend ICE in his son's name so that his son could take credit for the degree. Ranchoddas provides Chhote's address in Ladakh, where he is a schoolteacher. On the way, they pass Manali where they rescue and prevent Pia from marrying her materialistic fiancee Suhas. Chatur, meanwhile, is in a hurry to crack a business deal with world-renowned scientist and businessman with 400 patents to his name, Phunsukh Wangdu.
Upon arrival in Ladakh, the four head to the village school and witness the young students' inventions that resemble Rancho's college projects. The four happily reunite with Rancho to which Pia and Rancho kiss, while Chatur insults and asks Rancho to sign a contract stating that he is the least successful person; Rancho does so without commenting. As Chatur walks away triumphantly, Rancho reveals himself to be Phunsukh Wangdu, to his friends' and Pia's surprise and delight. Realizing this, a horrified Chatur accepts his defeat and pleads him to sign his contract while Rancho and his friends run away laughing. ReadMore>