After the death of Heath Ledger, production was shut down for a few months. Then it was re-started when Johnny Depp, Jude Law and Colin Farrell agreed to complete Ledger's role. The film's fantasy premise, and some clever rewrites, let the actors play a man whose appearance changes as he travels between imaginary worlds.
According to Terry Gilliam, the last line Heath Ledger spoke for filming on the set was "Don't shoot the messenger." When Johnny Depp filmed his role after Ledger's death, Depp asked Gilliam if he could try a new ad-lib: "Don't shoot the messenger", unaware that Ledger had improvised an identical line. Gilliam was astounded, remarking, "Heath is still out there. Johnny's channeling Heath somehow. I mean, Shirley MacLaine would love all this."
The film contains various references to the classic staging of Samuel Beckett's play Waiting For Godot including Tom Waits' black suit and bowler hat and Jude Law dragging a rope noosed around his neck (as does Lucky in the play)
Heath Ledger improvised half of his comedic dialogue on set.