Set during the tumultuous period of the early years of World War II, December 1941, this movie a set against the magnificent background of the Moroccan coastal city of Casablanca, whose idyllic beauty attracts people from all over the world, particularly Nazi-occupied Europe.
Many are transients trying to get out of Europe; a few are just trying to make a buck. Most of them -- gamblers and refugees, Nazis, resistance fighters, and plain old crooks -- find their way to Rick's Café Américain, a swank nightclub owned by American expatriate Rick Blaine (Humphrey Bogart).
Though we learn later that Rick once harbored enough idealism to put himself at risk to fight fascism, he's now embittered and cynical, professing to be neutral and detached: "I stick my neck out for nobody."
Ugarte (Peter Lorre) comes to Rick's with letters of transit he obtained by killing two German couriers. The papers allow the bearer to travel freely around German-controlled Europe, including to neutral Lisbon, Portugal; from Lisbon, it's relatively easy to get to the United States.
They are almost priceless to any of the refugees stranded in Casablanca. Ugarte plans to make his fortune by selling them to the highest bidder, who is due to arrive at the club later that night. However, before the exchange can take place, Ugarte is arrested by the police under the command of Captain Louis Renault (Claude Rains).
A corrupt Vichy official, Renault accommodates the Nazis. Unknown to Renault and the Nazis, Ugarte had left the letters with Rick for safekeeping, because "...somehow, just because you despise me, you're the only one I trust."
Then the reason for Rick's bitterness re-enters his life. Ilsa Lund (Ingrid Bergman) arrives with her husband Victor Laszlo (Paul Henreid) to purchase the letters. Laszlo is a renowned Czech Resistance leader who has escaped from a Nazi concentration camp. They must have the letters to escape to America to continue his work.
At the time Ilsa first met and fell in love with Rick in Paris, she believed her husband had been killed. When she discovered that he was still alive, she left Rick abruptly without explanation and returned to Laszlo, leaving Rick feeling betrayed. After the club closes, Ilsa returns to try to explain, but Rick is drunk and bitterly refuses to listen.
At different times Rick and Ilsa torment themselves by asking the club's piano player, Sam (Arthur "Dooley" Wilson), to play As Time Goes By, a song they loved when they were together in Paris. The famous line "Play it again, Sam," which refers to this song, doesn't actually appear in the movie -- Ilsa says "Play it, Sam," and later, Rick orders "Play it!"
While Sam plays the song, Rick reminisces about his affair with Ilsa in Paris. Though she seems happy to be with Rick, her mood near the end of their time together is cautious because she has learned her husband may not be dead. When the Nazis begin to close in on Paris, she receives word that Victor is indeed alive in another part of Europe.
She and Rick had been planning to take a train to Southern France to escape the German Army's assault; however, on the platform Rick receives a handwritten letter from her. She writes that she can't explain why she's leaving him but she loves him. Rick and Sam leave without her.
The next night, Laszlo, suspecting that Rick has the letters, speaks with him privately about obtaining them. They're interrupted when a group of Nazi officers, led by Major Strasser (Conrad Veidt), commandeer Sam's piano and begin to sing Die Wacht am Rhein (The Watch on the Rhine), a German patriotic song.
Infuriated, Laszlo orders the house band to play La Marseillaise in honor of Occupied France. The band leader looks to Rick for guidance; he nods. Laszlo starts singing, alone at first, then long-suppressed patriotic fervor grips the crowd and everyone joins in, drowning out the Germans. In retaliation, Strasser orders Renault to close the club.
Later that night, Ilsa confronts Rick in the deserted cafe. He refuses to give her the documents, even when threatened with a gun. She is unable to shoot, confessing that she still loves him. Rick decides to help Laszlo, leading her to believe that she will stay behind when Laszlo leaves.
Laszlo is jailed on a minor charge. Rick convinces Renault to release Laszlo, promising to set him up for a much more serious crime: possession of the letters of transit. However, Rick double crosses Renault, forcing him at gunpoint to assist in the escape.
At the last moment, Rick makes Ilsa get on the plane to Lisbon with her husband, telling her that she would regret it if she stayed: "Maybe not today. Maybe not tomorrow, but soon and for the rest of your life."
Major Strasser drives up, tipped off by Renault, but Rick shoots him when he tries to intervene. When his men arrive, Renault informs them that Strasser is dead and covers for Rick by sharply ordering them to "round up the usual suspects." He then recommends that they both leave Casablanca. Renault, suggesting they join the Resistance, walks into the fog with Rick who says "Louis, I think this is the beginning of a beautiful friendship."