Jake Gyllenhaal learned of the death of his close friend Heath Ledger while he was in the middle of shooting a scene for this film. Gyllenhaal immediately walked off set, and returned to finish the scene two days later. He then took a longer bereavement leave before he was ready to continue with the rest of his scenes.
Originally, Jake Gyllenhaal wanted to play Sam and Tobey Maguire wanted to play Tommy. Jim Sheridan did not feel Maguire was convincing enough to play the "bad" brother, so they switched roles.
During one intense early prison scene, Jake Gyllenhaal jokingly reached into his pocket and took out a picture of Ledger to stick on the prison wall. "Like those prisoners put [loved ones] on the wall, but Jake's was Heath Ledger," one set source recalls. "That was hilarious. It was a nice moment." (This was before Ledger's death).
Tobey Maguire nearly had to decline the lead role in Spider-Man 2 (2004) due to back injuries, and Jake Gyllenhaal was the top choice to replace him. While Gyllenhaal didn't receive the role because Maguire recovered in time, he did end up getting the role of Mysterio in Spider-Man: Far from Home (2019), released 15 years after Spider-Man 2. Maguire was also considered for the lead role in Jarhead (2005), which eventually went to Gyllenhaal.