Plot The film starts in Miami on the boat of crime lord Antonio Pope (Benjamin Bratt). His hacker A.J. (Ken Jeong) is going through a list on the computer. Pope calls Port Commissioner Griffin (James Martin Kelly) on the phone and accuses him of stealing money from him. With one of his hitmen in the room, Pope has Griffin killed in his apartment, then orders his men to find whoever stole his money.
In Atlanta, James (Ice Cube) is with his partner Detective Mayfield (Tyrese Gibson) as they try to infiltrate a car meet to find a drug dealer named Troy (Glen Powell). Ben (Kevin Hart), fresh out the academy, is eager to get in on the action, but James has him staying on the radio. James gets close enough to Troy, but Troy pulls a gun on him. Ben sees this over the camera and sneaks out to help. He rides into the meet in a showy car with hydraulics and draws unwanted attention to himself. He tries to threaten Troy by acting tough, only to drop his badge in front of the crook. A brief shootout occurs with Mayfield getting shot and Troy making his escape. James and Ben go after him, with Ben nearly getting himself run over, though James follows Troy long enough until Troy drives out of a parking garage and onto another car. James arrests Troy and swipes a necklace around him that is also a flash drive.
James reprimands Ben for his actions since he got Mayfield shot in the chaos causing him to take a leave of absence due to his injury. Lt. Brooks (Bruce McGill) assigns James to go to Miami and see who Troy was working for. Ben wants to go so that he can prove himself ready for detective work, but nobody believes in him, especially after the mess he just caused. At home, Ben is planning his wedding to Angela (Tika Sumpter), but he clashes with the wedding planner Cori (Sherri Shepherd). He tries to assert himself, but gets knocked out by the ceiling fan. Later, as Angela tries to seduce Ben, he complains about not being able to go to Miami. Angela calls James and tries to get him to take Ben, not just for himself, but so she can have him out of her hair while the wedding is planned. James refuses, but then changes his mind when he thinks he can prove that Ben doesn't have what it takes to be a detective. He goes to their house and officially invites Ben to Miami. James and Ben drive down to Miami together.
Ben starts his detective work by trying to blend in with the locals as they search for A.J. but Ben gets punished by homicide detective Maya Cruz for using her computer without permission. Later, James and Ben find the hacker, who tells them about a safe in a club that contains something important, but first they have to meet with someone there. The guys go to the club for work, but A.J. gets Ben to enjoy himself with an impromptu bachelor party. However, the man they are supposed to meet is also Pope's hitman. A.J. causes a distraction and escapes while James engages in a brief shoot-out with the hitman. Afterward, the two are met by Maya at the crime scene. The safe turned out to be empty. Before the guys can leave, James realizes a bomb was planted under his car, which goes off and destroys his car.
Ben realizes he kept A.J.'s phone on him, so they find his girlfriend Tasha to get a lead on his whereabouts. Ben convinces Tasha to spill the beans when he shows her that he's been hooking up with other women and given them unique ringtones, while Tasha is left with the generic Apple ringtone. The guys locate A.J. once more and bring him in on the investigation. He reveals to the team that Pope is the real crook, despite him having a public image as an entrepreneur working alongside the new port commissioner Nunez (Robert Pralgo). The team is at the home of Maya's friend/associate Alonso, whom Ben accidentally shoots after getting scared. Despite getting shot, Alonso backs up A.J.'s word that Pope is a crook.
James, Ben, and Maya go to a party hosted by Pope in his mansion. Maya distracts Pope by dancing with him while James and Ben gather info, and A.J. is their eyes and ears. Ben gets attacked by an alligator in the backyard. They get their information, but Pope catches them and knows they're cops, though he lets them go. The team uses their information to locate a group of shipping trucks that may be carrying Pope's contraband. However, when they attempt to stop the trucks at the port, they discover that the trucks are empty. Hernandez scolds the team, as Pope shows up and acts angry for what the team did. Nunez then shows up and calls Hernandez over. Brooks is informed of the screw-up and orders James to be suspended and for Ben to be fired.
The team goes to a bar to think about what they did wrong. Maya then questions as to why Nunez would have shown up so fast at the port. A.J. mentions that Nunez's name was on a list of guys on Pope's payroll. James realizes that Pope knew he would have gotten caught, so he had a decoy in the trucks, and the real contraband items are being brought in somewhere else at the port. James, Maya, and A.J. go after Pope, but Maya handcuffs Ben to a pole after James says he wants Ben to stay so he can take care of Angela. However, Ben breaks free and goes to Alonso's house to get the cuffs off.
James, Maya, and A.J. are at the port in the morning to catch Pope. They have a shootout with Pope and his goons, when Ben arrives and moves a truck to knock over a container with flammable barrels, causing them to explode. Pope runs and grabs A.J., then tries fleeing in a truck. James goes after him, but Ben knocks a container into Pope's path, causing him to crash. James runs to the truck and doesn't find Pope. Pope tries to shoot James, but Ben jumps in the way and takes the bullet. James shoots Pope a few times to bring him down, then sees that Ben was wearing a bulletproof vest. Pope rises and shoots again, but James uses Ben as a human shield, and Maya shoots Pope once more for good measure.
James and Ben are off the hook for taking down Pope and Nunez and being comended for their services. They drive home in a yellow Lamborghini that Maya got for them to drive back to Atlanta for the wedding, with James asking Maya to be his date. Ben and Angela are married and are ready to go off on a boat ride, but Ben wants James to make a speech. Reluctantly, James speaks and says that while Ben has gotten him into a lot of trouble since meeting him, he has also saved his life, has made Angela very happy, and has helped James grow into a better man and cop. He finally accepts Ben as his new family. Ben and Angela then go on their boat ride, but Ben gets distracted and is thrown out the boat when he rides over a bump. He is then dragged through the water by a rope as Angela tries to stop the boat, all while James laughs at this.