Morton Schmidt (Jonah Hill) and Greg Jenko (Channing Tatum) are former classmates who meet again at police academy. Schmidt was a nerd while Jenko was a jock. They end up becoming friends at the academy as they help with each others' weaknesses with Schmidt helping Jenko study and Jenko motivating Schmidt through physical activity. They graduate together as partners, but are assigned to park patrol. They catch a break when they spot a group of drug dealers and arrest their leader Domingo (DeRay Davis). However, the department is forced to release him as Jenko forgot to read the Miranda rights. The two are reassigned to a revived specialty division on 21 Jump Street.
They are introduced to Captain Dickson (Ice Cube), who explains the division specializes in infiltrating high schools and that they were chosen because of their youthful appearances. Schmidt and Jenko are assigned to go back to their old high school to stop a new synthetic drug from spreading to other campuses by finding the supplier. They go undercover as brothers, living at Schmidt's parents' house, and see that their high school has changed. Jenko accidentally switches their identities and they get each others' classes. They learn the lead dealer of the drug is the popular Eric (Dave Franco), but he is not the supplier.
They go to the dealing room where Eric forces them to take the drug right there and not wait. They attempt to throw it up but are unsuccessful, and they undergo the phases of the drug while talking to their P.E. teacher, Mr. Walters (Rob Riggle), and also while running track and during band practice. The mistakes that happen at the track meet causes Eric to take a liking to Schmidt.
Schmidt manages to fit in with the popular kids and takes a romantic interest in Eric's friend Molly (Brie Larson), while Jenko becomes friends with the nerds in his AP Chemistry class while his teacher Ms. Griggs (Ellie Kemper) takes a sexual interest in him. Jenko discovers that his new friends secretly tap into other people's cell phones to listen into their conversations. Schmidt decides to throw a party at his house to gain Eric's complete trust and Jenko takes the opportunity to tap into Eric's phone. Despite Captain Dickson ordering them not to serve alcohol and drugs to minors, they nevertheless buy alcohol and steal confiscated marijuana. When Eric arrives with Molly and his other friends, Jenko steals Eric's phone for his friends to tap into while Schmidt fights off a rival of Eric's and earns Eric's trust.
Schmidt now pretends to sell the drug for Eric but is actually giving it to Captain Dickson to be confiscated. While at Eric's house, Schmidt asks Molly out to prom while Jenko listens through Eric's phone. He also insults Jenko to Eric with Jenko listening. Schmidt and Jenko learn that Eric is making a deal soon. When Jenko spots Eric leaving school, he takes Schmidt to follow him. They see that Eric is dealing with Domingo and his gang and they follow them, but are forced to run away when Domingo spots them. Back at school, Jenko accuses Schmidt of his earlier insults, possibly ruining the case, and getting in too deep, but Schmidt brushes him off. Jenko and Schmidt get into a fight that results in them getting expelled and fired from Jump Street.
Later that night, both are confronted by Eric and his friends, who want to bring them on as security after hearing about what happened with Domingo. He tells them about a deal with Domingo happening during prom where they get to meet the supplier. At prom, they are surprised to see that the supplier is Mr. Walters. When Domingo and his gang arrive, he recognizes Schmidt and Jenko as police officers, and tells two of his men to kill them. However, the two men reveal themselves as DEA Agents Tom Hanson (Johnny Depp) and Doug Penhall (Peter DeLuise), who were a part of the Jump Street program when it began. Hanson casually talks to Schmidt and Jenko during the standoff which gives Domingo the opportunity to kill him and Penhall. A gunfight ensues between Schmidt and Jenko, Mr. Walters, and Domingo and his crew. Mr. Walters and Eric escape in a limo with Molly as a hostage, with Domingo and his crew in pursuit of them in another limo. Schmidt and Jenko pursue all of them in another limo where Jenko creates a homemade chemical bomb from his knowledge in AP Chemistry to kill Domingo and his crew. They then confront Mr. Walters, who shoots at Schmidt. Jenko jumps in front of Schmidt, saving his life and getting shot in the arm in the process. In response Schmidt shoots Mr. Walters in the groin, severing his penis. The duo successfully arrest him and Eric and make amends with each other. Schmidt makes amends with Molly and the two share a kiss. They are rehired into Jump Street where Dickson gives them a new assignment in a college setting, to Schmidt's excitement but to Jenko's dismay.