In the summer of 1946, Welles was directing a musical stage version of Around the World in Eighty Days, with a comedic and ironic rewriting of the Jules Verne novel by Welles, incidental music and songs by Cole Porter, and production by Mike Todd, who would later produce the successful film version with David Niven.
When Todd pulled out from the lavish and expensive production, Welles financed it. When he ran out of money and urgently needed $55,000 to release costumes which were being held, he convinced Columbia Pictures president Harry Cohn to send him the money to continue the show and in exchange Welles promised to write, produce and direct a film for Cohn for no further fee. As Welles tells it, on the spur of the moment, he suggested the film be based on the book a girl in the theatre box office happened to be reading at the time he was calling Cohn, which Welles had never read. However, according to the daughter of William Castle, it was her father who had purchased the film adaptation rights for the novel and who then asked Welles to pitch it to Cohn, with Castle hoping to receive the directoral assignment himself. She described her father as greatly respecting Welles' talents, but feeling nonetheless disappointed at being relegated to serve merely as Welles' assistant director on the film.
The Lady from Shanghai began filming on 2 October 1946, and originally finished filming on 27 February 1947, with studio-ordered retakes continuing through March 1947 - but it was not released in the U.S. until 9 June 1948. Cohn strongly disliked Welles's rough-cut, particularly what he considered to be a confusing plot and lack of close-ups (Welles had deliberately avoided these, as a stylistic device), and was not in sympathy with Welles's Brechtian use of irony and black comedy, especially in a farcical courtroom scene. He also objected to the appearance of the film - Welles had aimed for documentary-style authenticity by shooting one of the first major Hollywood pictures almost entirely on location (in Acapulco, Pie de la Cuesta, Sausalito and San Francisco) using long takes, and Cohn preferred the more tightly-controlled look of footage lit and shot in a studio. Release was delayed due to Cohn ordering extensive editing and reshoots. Whereas Welles had delivered his cut of the film on time and under budget, the reshoots Welles was ordered to do meant that the film ended up over budget by a third, contributing to the director's reputation for going over budget. Once the reshoots were over, the heavy editing ordered by Cohn took over a year to complete; veteran editor Viola Lawrence cut about an hour from Welles's rough cut. Welles was appalled at the musical score and particularly aggrieved by the cuts to the climactic confrontation scene in an amusement park funhouse at the end of the film. Intended as a climactic tour-de-force of editing and production design, the scene was cut to fewer than three minutes out of an intended running time of twenty. As with many of Welles's films over which he did not have control over the final cut, the missing footage has not been found and is presumed to have been destroyed. Surviving production stills show elaborate and expensive sets built for the sequence which were entirely cut from the film.
Welles cast his wife Rita Hayworth as Elsa and caused controversy when he made her cut her famous long red hair and bleach it blonde for the role. "Orson was trying something new with me, but Harry Cohn wanted The Image — The Image he was gonna make me 'til I was 90," Rita Hayworth recalled. "The Lady from Shanghai was a very good picture. So what does Harry Cohn say when he sees it? 'He's ruined you — he cut your hair off!'"
The film was considered a disaster in America at the time of its release, though the closing shootout in a hall of mirrors has since become one of the touchstones of film noir. Not long after release, Welles and Hayworth finalized their divorce.
A remake of the film came close to production at the turn of the century from a screenplay written by Jeff Vintar, based both on the Orson Welles script and the original pulp novel, produced by John Woo and Terence Chang, and starring Brendan Fraser, who wanted Michael Douglas and Catherine Zeta-Jones to co-star. Although the screenplay was considered highly successful, and Fraser was coming off the highly praised Gods and Monsters, the project was abandoned when the head of Sony Pictures, Amy Pascal, decided to concentrate on teen films.
In addition to the Columbia Pictures studios, the film was partly shot on location in San Francisco. It features the Sausalito waterfront and Sally Stanford's Valhalla waterfront bar and cafe, the front, interior, and a courtroom scene of the old Kearny Street Hall of Justice, and shots of Welles running across Portsmouth Square, escaping to a long scene in a theater in Chinatown, then the Steinhart Aquarium in Golden Gate Park, and Whitney's Playland-at-the-Beach amusement park at Ocean Beach for the famous hall of mirrors scene, for which interiors were shot on a soundstage.
Other scenes were filmed in Acapulco. The yacht Zaca, on which many scenes take place, was owned by actor Errol Flynn, who skippered the yacht in between takes and can also be seen in the background in one scene at a cantina in Acapulco.