In the end, Detectives Gamble and Hoitz bring down David Ershon (but not Lendl Global) and find personal happiness and respect in the police department - even if they aren't the flashiest of cops. They continue to investigate financial crimes with the help of real-life NY Yankees shortstop/legend Derek Jeter.
After super-cops Highsmith and Danson (Samuel L. Jackson and Dwayne "The Rock" Johnson respectively) inadvertently kill themselves in a pursuit of diamond thieves, all the cops in the apartment attempt to fill the role as NYC's new bad-ass "Lethal Weapon" style enforcers. The worst cops in the station are Detectives Allen Gamble (Will Ferrell) a former pimp and forensic accountant who has a wooden gun because he can't handle a real one, and his partner Terry Hoitz (Mark Wahlberg) who is disgraced since he accidentally shot Yankees legendary shortstop Derek Jeter (who plays himself) while on simple guard duty during the playoffs. The two are in constant friction as Gamble, despite his brilliance and animal magnetism, doesn't want to let his dark side reemerge and Hoitz is too hotheaded because, as he often proclaims, he is a peacock that the department won't allow to fly. Further, Gamble constantly denigrates his super-hot and super-sexual wife Dr. Sheila Gamble (Eva Mendes) while Hoitz' attitude has caused him to lose his long-time girlfriend Francine (Lindsay Sloane) who he hopes to win back.
After Hoitz drags Gamble to the scene of a diamond-heist where they embarrass themselves, Gamble drags Hoitz to a hotel where they arrest billionaire investor David Ershon (Steve Coogan) for simple building code violations. Unknown to them, Ershon's poor investments have have caused the mysterious corporation Lendl Global to suffer multi-billion dollar losses. Lendl Global has dispatched a team of mercenaries led by Roger Wesley (Ray Stevenson) to help Ershon complete a mysterious scam to cover the losses. A running gag throughout the film is that whenever Ershon is taken into the detectives' custody, Wesley and his crew help to bust him out, strand Hoitz and Gamble in exotic locales without their shoes, and leave Gamble's car in a bad part of town where hobos engage in orgies in the car.
Everyone warns Gamble and Hoitz to stop the investigation, including the FCC, the District Attorney and Police Captain Gene Mauch (Michael Keaton) who also is a manager at Bed, Bath and Beyond for extra money. Further, Wesley's attempts on the detectives' lives become more intense, and both women end up rejecting their respective men. The detectives believe Ershon is responsible for the diamond heist, but when they are proven wrong, Captain Mauch demotes them both and breaks up their partnership. Gamble continues investigating, however, and soon discovers that Ershon is intending to strike a deal to run the police pensions, and will instead embezzle the pension fund to cover the losses for not only Lendl Global, but also to the Nigerian and Chechan mafia who he also owes money too. He discovers that the diamond heist was only a ruse for Wesley to break into the nearby accounting firm and cook Lendl Global's books. Captain Mauch authorizes Gamble to go ahead with the investigation and also says that Highsmith and Danson were bad cops despite their high public profile. Gamble reunites with Hoitz and they abduct Ershon (becoming NYPD public enemy number 1 , thus resulting in the three being hunted by Wesley, the Nigerians, the Chechans, and the NYPD). The three (Ershon unwillingly) intend to stop the transfer of the pension funds the next morning. The two detectives, fearing death, also repair their respective relationships with their significant others.
The next day, Gamble and Hoitz avoid the NYPD, Chechans, and Nigerians to arrive at Ershan's office to stop the transfer of the police pension. However, they are encountered there by Wesley's armed crew and both Gamble and Hoitz are shot and wounded. As it looks like the transaction is about to go through, the NYPD arrives, led by Captain Mauch, to take down Stevens and stop the transfer. The captain's faith in the detectives are restored, and they gain the respect of their peers (although it seems that their rival detectives Martin and Fosse will take Highsmith and Danson's roles as the high-profile super-cops, Gamble and Hoitz have proven to be better actual cops).
The ending then occurs as follows (rapper/actor Ice-T narrates both this, and the entirety of the movie).
AFTER THE CREDITS:
A scene with Hoitz telling a long joke to Gamble at a Chinese restaurant in an attempt to prove he is funny too.