Maxwell Anderson's verse play Key Largo premiered on Broadway in 1939, with Paul Muni in the lead as a disillusioned veteran of the Loyalist Army in the Spanish Civil War who travels to the Florida Keys to visit the family of a fallen comrade. There he discovers the family's hotel has been taken over by a vicious gambler's mob and has to overcome his war-weariness to fight against the crooks.

Warner Bros. bought the screen rights to Anderson's play on July 25, 1947, three days after John Huston finished shooting The Treasure of the Sierra Madre (1948). He was asked to direct with Jerry Wald as producer, and Humphrey Bogart was approached about playing the male lead. They also signed up-and-coming screenwriter Richard Brooks, who already was a friend of Bogart's, to collaborate on the screenplay.

Huston did not like the original play and considered turning the film down. Eager to work with the director, Brooks tried to change his mind. Finally Huston agreed to look at a story treatment by Brooks to see if the writer could develop an approach he thought would work. When Brooks updated the story to make Bogart's character a World War II veteran and turn the gambler into a deported mobster sneaking back into the country, Huston agreed the film could work. Brooks also added a hurricane and the final shipboard sequence to give the film more action. The shipboard shootout is borrowed from the ending of Ernest Hemingway's novel To Have and Have Not, which had not been used in Warner Bros.'s 1944 screen version.

In November 1947, Huston and Brooks traveled to Key West for atmosphere as they worked on the script. When they found out Key Largo had only one hotel, which was already closed for the season, they tracked down the owner and convinced him to open it up for them. There Brooks wrote in the morning while Huston fished. Then Huston would read Brooks's work and go out to the pier to think about it.

Huston and Brooks modeled the gangster character largely on Charles "Lucky" Luciano, who had secretly moved to Cuba after being deported. Until his death, there were frequent rumors that he planned to sneak back into the U.S.

Rocco's mistress, the alcoholic former singer Gaye Dawn, was modeled on Luciano's mistress Gay Orlova. In the original play, the gambler had two mistresses, but Brooks and Huston felt having just one would create a better role.

Huston thought the villain's first entrance in the play, in which he simply comes down the stairs, was boring, but he couldn't come up with a stronger way of introducing the character. Then he walked in on Brooks trying to cool off by soaking in a cool bathtub with the fan blowing on him. That inspired the character's on-screen introduction, which Huston would later call the film's high point. He likened the image to "a crustacean with its shell off." (John Huston, quoted in Lawrence Grobel, The Hustons)

The Production Code Administration objected to the script because of its depiction of a gangster, a type of character moralists were trying to keep off the screen. Producer Jerry Wald successfully argued that they had approved other films with gangsters at other studios, but the PCA still demanded the deletion of references to the gangster's involvement in the vice racket and narcotics. As a result, the character began to resemble Al Capone rather than Luciano.

Lauren Bacall was happy to accept the relatively straight role of Nora Temple, the war widow who falls for Bogart's character. For one thing, she was eager to work with family friend Huston. For another, her career had not been doing that well at Warner Bros., where she had a made a strong film debut opposite Bogie in To Have and Have Not. Some of the studio's assignments for her were so unsuitable, in her opinion, that she kept turning them down and going on suspension. Before Key Largo she had been on suspension for turning down two films, the musical Romance on the High Seas (1948), which became Doris Day's film debut instead, and the Western Stallion Road (1947), which went to Alexis Smith.

Huston's first choice to play the gangster was Charles Boyer, but Jack Warner vetoed the unconventional casting. Then the director settled on Edward G. Robinson, who had become a star in similar roles, most notably as the title character in Little Caesar (1931). In fact, Huston changed the character's name from Murillo to Johnny Rocco to echo Robinson's name in that film, 'Rico' Bandello.

Robinson had left Warner Bros. six years earlier for fear of being typecast in gangster roles. At the time he signed for Key Largo, his career was at a low ebb as he was being investigated for his liberal politics. As a result, he had to accept second billing to Bogart. More artist than ego, Robinson took his fall from stardom philosophically. In his memoirs, he wrote, "The journey down. No suspense to this. I didn't even argue [about his billing]. Why not second billing? At 52 I was lucky to get any billing at all." (Edward G. Robinson, All My Yesterdays

For the role of Bacall's father-in-law, Warner Bros. borrowed Lionel Barrymore, a longtime MGM star who had not appeared in a Warner's film since his talkie debut in The Lion and the Mouse (1928). By that point in his life, the actor was confined to a wheelchair after a series of crippling illnesses. He also was in almost constant pain, but never complained.

Claire Trevor and Bogart were yachting buddies and had their boats docked next to each other on Catalina Island. When she heard about the Key Largo script and his commitment to star, she got her husband to approach Bogart personally, which he did at a steam bath. Her husband told Bogart Trevor wanted to play the alcoholic ex-mistress and suggested he pitch her casting to Jack Warner, which Bogart did.

Huston rehearsed the script for three weeks before filming began. He kept Brooks around during that period for last-minute rewrites. Knowing the writer was interested in directing one day, he also encouraged him to visit the set during filming and explained some of his directorial techniques to him.

By Frank Miller