In the year 1999, Farhan Qureshi and Raju Rastogi begin their college year in the prestigious Imperial College of Engineering (ICE) in Delhi. They are joined by Ranchoddas Chanchad, nicknamed “Rancho”, as their roommate. They meet Manmohan a.k.a. “Millimetre”, an adolescent boy helping the students . He is persuaded by Rancho to sneak into school and get educated. 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 and is always afraid of failing. Rancho, on the other hand, is genuinely passionate 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, 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, nicknamed “Silencer” (because of his nature of silently farting), is an arrogant student with little knowledge of Hindi due to his Ugandan-Tamilian upbringing, who is obsessed with topping the exams and invariably learns by rote.
Sometime later, the trio finds that a student named Joy Lobo, whose interest in machines was as much as Rancho, committed suicide by hanging himself, which was caused by depression after Virus informs Joy’s father that Joy would be unable to graduate that year due to a delay in his submission of an assignment. Joy had taken longer as he wanted to perfect his breakthrough drone design of a quad-copter, and also due to a break on account of his father’s brief illness. Rancho criticises 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 gatecrashes the wedding of Virus’ elder daughter, Mona to eat good food. They meet and befriend Pia, who turns out to be Virus’ younger daughter and a resident student at the city’s hospital. Rancho advises Pia not to marry her fiancée Suhas Tandon because he’s madly obsessed with expensive jewellery, brands, and prices and has no true love for her. Rancho gives Pia a demo on Suhas’ attitude by spilling mint sauce on his shoes to annoy him. When Virus spots the trio, he summons Farhan and Raju on the next working day and tells them of the consequences of being friends with Rancho by comparing their families’ incomes. 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 and into 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, Pia is at the mall with Suhas and spots Rancho with an invention named after Virus; The Virus Inverter. Rancho explains to Pia that he dislikes the way her father teaches his students and that they end up lame like Suhas. Rancho plays a prank on Suhas, pretending that Pia lost her watch, to prove that Suhas shows more value to expensive stuff rather than her. Fed up with Suhas’ behaviour, she tells him off. Rancho and Pia save Raju’s dying father; Raju reconciles with his friends while Pia falls in love with Rancho.
One night during their senior year, Farhan and Raju are upset that they are trailing behind in their grades every year and that Rancho is always in the front of every school picture. Farhan exposes Rancho of not telling Pia that he is in love with her and hasn’t told her for the past four years. The three friends drunkenly break into the Sahastrabuddhe residence so that Rancho can propose to Pia. As the trio escape, Virus recognises Raju and, on the next day, threatens to expel him unless he writes a letter recommending Rancho for expulsion. 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 his first job interview on the campus, which he succeeds in cracking. Meanwhile, Rancho and Pia post Farhan’s letter to his favourite Hungarian wildlife photographer Andre Istvan, who offers him a position as an assistant. On Rancho’s advice, he communicates his dream to his father, who though reluctant at first, gives his blessings for the sake of his son’s happiness.
Infuriated by this and Rancho’s influence, Virus sets a difficult final exam paper to fail Raju, wherein Pia tries to help the trio by revealing to them the location of the exam paper in her father’s office; unfortunately, Virus finds out and expels them. Pia confronts Virus about her brother who had committed suicide because he couldn’t meet Virus’ expectation of clearing the engineering exam. That same night, the pregnant Mona goes into labour during a heavy storm that cuts off all traffic and electricity in the city. Rancho and the other students help them by using 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.
Ten years later, in 2009, 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 married and the vice-president of a reputable corporation in the United States wanting to crack a business deal with a world renowned scientist and businessman with 400 patents to his name, Phunsukh Wangdu for whom he has been asking an appointment for over 1 year ; none among the three of them have heard from Rancho since graduation. Reuniting at the ICE campus, after Chatur reminds them about the bet,they travel to Shimla, where Rancho was spotted in the background of a snapshot taken by Chatur’s secretary, Tracy, who was trying to get an appointment with Wangdu. Chatur then went through the Shimla directory and found the address of Rancho. Upon arrival, they meet a man who turns out to be the real Ranchoddas Chanchad (Javed Jaffrey) at his father’s funeral and the photos of the Rancho they knew replaced with the real one. From him, Farhan and Raju learn that the Rancho they knew was actually “Chhote”, the smart son of the gardener who was a servant to the Chanchad family who would sneak into school wearing Ranchoddas’ old uniform and help Ranchoddas with his schoolwork until he was found out by a teacher who told Ranchoddas’ father.Ranchoddas’ father then arranged for Chhote to attend ICE in his son’s name so that Ranchoddas could take credit for the degree while he was in London for 4 years . He also told Chhote to cut off all contact with his ICE friends after graduating but Chhote was sure that Farhan and Raju would come looking for him. Ranchoddas provides Chhote’s address in Ladakh, where he is a schoolteacher. On the way, they pass Manali where against Chatur’s wishes, they rescue and prevent Pia from marrying Suhas, who is now a changed man but reverts to his old ways when Raju, disguised as the housekeeping man, puts mint sauce on his wedding jacket, making Raju run away from the wedding in his attire.
Upon arrival in Ladakh, the four head to the village school and witness the young students’ inventions that resemble Chhote’s college projects. They are reunited with the adult educated Manmohan, now going by the nickname “Centimetre” who has now become a helper for Chhote after receiving a letter from him to help him. He tells them that Chhote never forgot about them, stealing and keeping Pia’s scooter helmet as a memento, reading Farhan’s photography books and Raju’s blog. He then tells them where to find Chhote. The four happily reunite with Chhote to which Pia and Chhote smooch, while Chatur, unaware of Chhote’s secret thinking he is Rancho, insults and asks Chhote to sign a contract stating that he is the least successful person; Chhote does so without commenting. As Chatur walks away triumphantly, Chhote reveals that his real name is 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 Phunsukh and his friends run away laughing. In the end, Wangdu tells everyone his theory: “Follow excellence and success will by itself follow you”.