It is early December 1941. American expatriate Rick Blaine (Humphrey Bogart) is the proprietor of an upscale nightclub and gambling den in Casablanca. "Rick's Café Américain" attracts a varied clientele: Vichy French, Italian, and German officials; refugees desperate to reach the still neutral United States; and those who prey on them. Although Rick professes to be neutral in all matters, it is later revealed he ran guns to Ethiopia and fought on the Loyalist side in the Spanish Civil War.
Black-and-white film screenshot of several people in a nightclub. A man on the far left is wearing a suit and has a woman standing next to him wearing a hat and dress. A man at the center is looking at the man on the left. A man on the far right is wearing a suit and looking to the other people.
Petty crook Ugarte (Peter Lorre) shows up and boasts to Rick of "letters of transit" obtained by murdering two German couriers. The papers allow the bearer to travel freely around German-controlled Europe and to neutral Portugal, and are thus almost priceless to the refugees stranded in Casablanca. Ugarte plans to sell them at the club later that night. Before he can, however, he is arrested by the local police under the command of Vichy Captain Louis Renault (Claude Rains), an unabashedly corrupt official. Ugarte dies in custody without revealing that he had entrusted the letters to Rick.
At this point, the reason for Rick's bitterness—his former lover, Norwegian Ilsa Lund (Ingrid Bergman)—walks into his establishment. Upon spotting Rick's friend and house pianist, Sam (Dooley Wilson), Ilsa asks him to play "As Time Goes By". Rick storms over, furious that Sam has disobeyed his order never to perform that song, and is stunned to see Ilsa. She is accompanied by her husband, Victor Laszlo (Paul Henreid), a renowned fugitive Czech Resistance leader. They need the letters to escape to America, where he can continue his work. German Major Strasser (Conrad Veidt) has come to Casablanca to see that Laszlo does not succeed.
When Laszlo makes inquiries, Ferrari (Sydney Greenstreet), a major underworld figure and Rick's friendly business rival, divulges his suspicion that Rick has the letters. In private, Rick refuses to sell at any price, telling Laszlo to ask his wife the reason. They are interrupted when Strasser leads a group of officers in singing "Die Wacht am Rhein". Laszlo orders the house band to play "La Marseillaise". When the band looks to Rick, he nods his head. Laszlo starts singing, alone at first, then patriotic fervor grips the crowd and everyone joins in, drowning out the Germans. In retaliation, Strasser has Renault close the club.
That night, Ilsa confronts Rick in the deserted café. When he refuses to give her the letters, she threatens him with a gun, but then confesses that she still loves him. She explains that when they first met and fell in love in Paris, she believed that her husband had been killed attempting to escape from a concentration camp. Later, while preparing to flee with Rick from the imminent fall of the city to the German army, she learned that Laszlo was alive and in hiding. She left Rick without explanation to tend her ill husband.
The lovers are reconciled. Rick agrees to help, leading her to believe that she will stay with him when Laszlo leaves. When Laszlo unexpectedly shows up, having narrowly escaped a police raid on a Resistance meeting, Rick has waiter Carl (S. K. Sakall) spirit Ilsa away.
Laszlo, aware of Rick's love for Ilsa, tries to persuade him to use the letters to take her to safety. When the police arrest Laszlo on a minor, trumped-up charge, Rick convinces Renault to release him by promising to set him up for a much more serious crime: possession of the letters of transit. To allay Renault's suspicions, Rick explains he and Ilsa will be leaving for America.
When Renault tries to arrest Laszlo as arranged, Rick forces him at gunpoint to assist in their escape. At the last moment, Rick makes Ilsa board the plane to Lisbon with her husband, telling her she would regret it if she stayed, "Maybe not today, maybe not tomorrow, but soon and for the rest of your life."
Strasser, tipped off by Renault, drives up alone. Rick shoots him when he tries to intervene. When the police arrive, Renault pauses, then tells them to "round up the usual suspects." Renault suggests to Rick that they join the Free French at Brazzaville as they walk away into the fog.