MSP sets up a sting, but Sullivan tips off Costello, allowing everyone to escape. Costello realizes there is a spy in his crew and tasks Sullivan to find him. Sullivan asks Costello for information on his crew to cross-reference against the MSP database. Meanwhile, Costigan learns that Costello is a protected FBI informant, and Costello accuses Costigan of being the spy, which he denies. Costigan shares his discovery with Queenan and warns him that Costello is aware of a spy in his ranks. Dignam tells him that he believes Costello has his own spy in the MSP. Other than Queenan and Dignam, Costigan's only contact in the MSP is his police-appointed psychiatrist, Madolyn Madden, who is also Sullivan's girlfriend. Costigan and Madolyn later have an affair. Costigan follows Costello into a theater and witnesses him giving Sullivan an envelope. Queenan instructs Costigan to get a visual ID of Sullivan but he is unable to get a good look at Sullivan's face. When Sullivan realizes that he is being followed, he mistakenly stabs a restaurant worker and flees. Sullivan tries to cross-reference Costigan's picture, captured by nearby security footage, against police officer databases but cannot identify him. Queenan advises Sullivan to follow Costello to find the MSP mole. Costigan calls Queenan and sets up a meeting but Sullivan has Queenan followed, lying to the other officers that Queenan may be the spy. Sullivan also calls in Costello's gang to the meeting location. When Costello's men arrive, Queenan helps Costigan escape before being thrown from the building's roof to his death. Angered by Queenan's murder, Dignam blames and attacks Sullivan and is suspended by Ellerby. One of Costello's wounded henchmen, Timothy Delahunt, tells Costigan that he knows Costigan is the rat, but he succumbs to his injury before he can alert the others. Newspapers report that Delahunt was an undercover officer for the Boston Police but Costello suspects the police department made up the claim so he would stop looking for the mole. Sullivan also learns that Costello is an FBI informant and decides to turn on him. Costello is tailed by the MSP to a cocaine drop-off, where a gunfight erupts, killing most of Costello's crew. Sullivan confronts Costello, who admits to being an FBI informant, and fatally shoots him. His assignment finished, Costigan goes to Sullivan to reveal his undercover status. He notices Costello's envelope of gang member information on