The plot of "The Departed" is a series of escalating betrayals and revelations that culminate in a bloody and tragic finale. The central twist is the parallel nature of the two moles: Billy Costigan, a cop deep undercover in Frank Costello's crew, and Colin Sullivan, Costello's man inside the Massachusetts State Police. A major turning point is the revelation that the seemingly untouchable mob boss, Frank Costello, is himself a protected FBI informant, which is why he has evaded capture for so long. This discovery motivates Sullivan to orchestrate Costello's death to protect his own identity.
After Costello's demise, Billy comes to Sullivan to have his identity restored, but he discovers evidence in Sullivan's office that exposes him as the other mole. The climax is a rapid succession of violent deaths. Billy is unexpectedly shot and killed by another of Costello's moles in the police force, Trooper Barrigan, just as he is about to expose Sullivan. Sullivan then kills Barrigan to eliminate the last witness to his treachery, effectively framing Barrigan as the sole informant. Sullivan appears to have gotten away with everything, but in the final scene, he is ambushed and killed in his apartment by Sergeant Dignam, who has seemingly been given the incriminating evidence against Sullivan by Billy's psychiatrist and Sullivan's ex-girlfriend, Madolyn. The film's final shot is of a rat on Sullivan's balcony, a final, stark symbol of the pervasive betrayal.