This was originally commissioned as a directing vehicle for Wolfgang Petersen. However, there were considerable modifications made to Dennis Lehane's novel in order to create a more action-driven blockbuster.
When Paramount Pictures first developed this as a project for the director/star team of David Fincher and Brad Pitt, Mark Wahlberg was wanted for the opposite leading role (as this is a Boston-set story). However, Fincher and Pitt moved on to other commitments. Paramount almost signed on the star duo of Pitt and Wahlberg for another Boston-set drama, The Fighter (2010), a couple years later. Pitt eventually had to drop out of that project, as well.
Many parts were filmed in the old Massachusetts state mental hospital in Medfield, MA.