The boxcar scene--where Jack Walsh (Robert De Niro) and John Mardukas (Charles Grodin) discuss whether or not they could ever be friends--was almost entirely improvised on-set. Regarding Grodin's famous line, "You ever had sex with an animal, Jack?": he was told by director Martin Brest to come up with something that was guaranteed to make even Robert De Niro laugh.
Actor Yaphet Kotto (Agent Alonzo Mosely) commented in a 2015 interview: "Midnight Run was practically the most difficult movie I ever made. Marty Brest doesn't do one take. He shoots a lot of footage, one take after another, all kinds of different ways, experimenting to see if something extraordinary happens. Then even if it does he'll try something else. [...] I didn't know whether it was a comedy or a drama. It could go either way. What I was surprised about is what I thought was going to be funny was funny, and what I thought was going to be dramatic was even funnier".
The idea to have Jack Walsh (Robert De Niro) continually checking his watch--and the whole back-story related to his habit--was all De Niro's idea.
Paramount Pictures originally owned the rights to the film. To improve the film's chances at the box office, the studio wanted a big-name star to appear opposite Robert De Niro. It was suggested that the character of John "Duke" Mardukas be changed to a woman and be played by Cher, who had had recent box-office success with The Witches of Eastwick (1987), Suspect (1987), and Moonstruck (1987). It was felt that casting Cher opposite De Niro would lend some "sexual overtones" to the relationship between the two characters. Director Martin Brest rejected the gender switch idea, so Paramount Pictures suggested giving the role to Robin Williams, who had recently had a big hit with Good Morning, Vietnam (1987). Williams read and liked the script and agreed to audition. In the meantime, however, Brest had auditioned the less famous Charles Grodin and had liked Grodin's interaction with De Niro. As such, Brest cast Grodin without auditioning Williams. Paramount Pictures decided to drop out of the project, selling the rights to Universal, who went ahead with the De Niro and Grodin casting.
Charles Grodin had permanent scars resulting from the real handcuffs he had to wear for a great deal of the film. Even though they had rubber and plastic handcuffs that could be used in wide shots, Robert De Niro, ever the method actor, encouraged Grodin to wear the steel ones in most scenes.