As Father Peter and Father Daniel proceed with the exorcism of Charlie, they take him to a police station, where he goes on a killing spree. Eventually, Peter and Daniel manage to escape with Charlie without being killed, but Peter leaves the performance of the exorcism to Daniel. Daniel eventually realizes that Peter is actually the one who's been possessed, and he begins to perform an exorcism on his mentor.
Peter fights back in retaliation, but Daniel then stabs Peter in the neck with a pectoral cross. This killing meshes with the opening scene of the film, which is set 25 years earlier, and features a young Peter witnessing the murder of his own mentor by a possessed boy in a similar fashion. After Peter is stabbed, the demon that was residing inside of him tries to possess Daniel, but Daniel is ultimately able to resist the possession and escape.
In the film's closing moments, the archbishop (Stephen Lang) gives Peter's case files to Daniel. These make it clear that Peter was actually possessed by a demon back in 1995. Since then, every priest who has worked under Peter has been possessed by a demon, creating a network of demonic priests that is now quite sizable. Daniel was the first priest who was able to resist this possession.