Michael Curtiz's 1942 classic begins with a male narrator explaining that right before World War II, refugees from Occupied Europe were desperate to escape to America. However, the common point of exit was Lisbon, and there was often no easy way to get there, so many made the perilous journey to Casablanca, in Morocco (Unoccupied France). There, people would do whatever they could to procure exit visas to make their way out.
In Casablanca, tensions are high because two German couriers have been murdered on a train from Oran. Major Heinrich Strasser of the Third Reich arrives in Casablanca to investigate the case, which is being overseen on the ground by Vichy Captain Louis Renault (Claude Rains). Renault assures his superior that everything is under control and promises to turn over the alleged murderer that night at Rick's Café Americain.
That evening, Rick's Café is crowded and lively as usual. A piano player named Sam (Dooley Wilson) provides the music for a mixed clientele of military officers, desperate refugees, black market dealers, and shady gamblers. The cafe's owner, Rick Blaine (Humphrey Bogart), however, is not partaking in the revelry. In fact, as Carl the waiter enforces, Rick never drinks with customers because he would not want to do anything to endanger his firm political neutrality. However, a slippery local criminal named Ugarte (Peter Lorre) asks Rick to safeguard two Letters of Transit (equivalent to exit visas) which he plans to sell. Rick agrees to hold onto the letters - which, it is inferred, Ugarte stole after murdering the German couriers - but only for a short period of time. Renault informs Rick that there is another reason for Major Strasser's arrival in Casablanca: a notorious dissident, Victor Laszlo (Paul Henreid), who has escaped from the Gestapo several times, will soon be arriving in Casablanca. Renault reveals that in the past, Rick has fought on the side of the underdog: he ran guns to Ethiopia and helped the Loyalist cause in Spain. Rick claims not to harbor leftist beliefs anymore, but still bets Renault 10,000 Francs that Laszlo will escape again.
Major Strasser (Conrad Veidt) enters Rick's Café and Renault makes sure to capture Ugarte in the most public and theatrical way possible. Rick refuses Ugarte's cries for help, stating flatly, "I stick my neck out for nobody." Major Strasser tries to engage Rick and already has a full file on him. Rick is not fazed by the Major's intimidation tactics. Soon, Victor Laszlo himself enters Rick's Café, accompanied by Ilsa Lund (Ingrid Bergman). Apparently Laszlo had arranged to purchase the Letters of Transit from Ugarte, who he learns has been captured. Hence, Laszlo and Ilsa will not be able to get out of Casablanca easily. Renault and Major Strasser both clock the pair's arrival. Meanwhile, Ilsa clearly knows Sam, and asks him to play a song called "As Time Goes By." Rick comes in and sees Ilsa, and it is clear that they have a past. They knew each other some time ago in Paris, and have not seen one another since the Germans invaded.
Late that night, Rick unravels. He recalls his passionate love affair with Ilsa in Paris, a woman who he knew nothing about. As Rick gets drunker, he demands that Sam play "As Time Goes By." He and Ilsa were happy together, but Rick is on a German blacklist due to his anti-Fascist activities, and so they could not stay in Paris once Hitler's army invaded. He and Ilsa made plans to meet at the train station and run off to Marseilles, but Ilsa abandoned Rick, leaving him a note telling him not to come looking for her. Just as he's emerging from his drunken reverie, Ilsa enters Rick's and tries to tell him that she did love him. He is cold and cruel towards her, and she leaves the cafe in tears.
Major Strasser strongly suspects that Rick has the missing Letters of Transit, which Renault can neither confirm nor deny. Nevertheless, Strasser offers a deal to Ilsa and Laszlo. If Laszlo will give up names of resistance leaders, then Major Strasser will arrange for their safe passage to America. Laszlo, without flinching, refuses.
Later, Rick finds Ilsa at a bazaar. He tries to apologize for his behavior the night before, but Ilsa has shut down. She refuses to tell him why she abandoned him and hopes that their fond memories have not been tainted by Rick's anger and pain. Ilsa and Laszlo go to Signor Ferrari, an Italian businessman who is responsible for most of Casablanca's black market economy. He says that getting Laszlo out of Casablanca would be impossible but he can arrange for Ilsa to leave alone. They refuse. The only chance Ilsa and Laszlo have of getting out of Casablanca safely is Rick Blaine and the Letters of Transit.
That night at Rick's, political tensions escalate between French and German soldiers, forcing Major Strasser to request Renault to shut the cafe down. Regardless of the danger he faces, Victor Laszlo goes off to an Underground Resistance meeting, and Ilsa sneaks into Rick's apartment. She begs Rick for the letters of transit, because without an escape plan, Victor Laszlo will die in Casablanca. Rick refuses, until Ilsa points a gun at him. They both break down, and Ilsa confesses to the real reason why she abandoned Rick in Paris. Before she met Rick, her husband, Victor Laszlo, was captured and taken to a concentration camp and Ilsa got the news that he died there. However, right before she and Rick were supposed to leave for Marseilles, Laszlo reappeared, alive. She knew if she told Rick the truth he would not go, and she feared for his safety.
Laszlo is arrested on petty charges after the Underground Resistance meeting is broken up. He asks Rick to use the two Letters of Transit to take Ilsa away from Casablanca. Laszlo loves his wife so much that he's willing to let her go so that she will be safe. Afterwards, Rick makes a deal with Renault. He will arrange for Laszlo to be caught purchasing the stolen letters, which will give Renault grounds to send Laszlo to a concentration camp and therefore, impress Major Strasser. Then, Rick and Ilsa will be able to escape safely. Renault agrees. However, when Renault arrests Laszlo, he turns around to find Rick pointing a gun at him. Renault manages to tip off Major Strasser as Rick forces him at gunpoint to accompany them to the airport and sign over the Transit Letters to Victor Laszlo and Ilsa Lund.
At the airport, Rick and Ilsa share a fond goodbye and console themselves in the fact that they will always have Paris. Laszlo thanks Rick for his sacrifice, for he knows (despite Rick's proclamations of the opposite) that Rick still loves Ilsa. However, Rick recognizes that Laszlo needs Ilsa to keep fighting against the Third Reich, and that is more important than Rick's longing heart. As soon as Laszlo and Ilsa get on the plane to Lisbon, Major Strasser arrives and tries to have the plane turned around. He pulls a gun at Rick but Rick shoots him first, and he falls. The only witness to the murder is Renault. When the local police arrive, Renault informs them that Major Strasser has been shot and instructs them to "round up the usual suspects", thus saving Rick.
In the last shot, Rick and Renault walk away into the night, making plans to go to the Free French Garrison in Brazzaville, for what will be the "beginning of a beautiful friendship."