In May 1940, during World War II, the Nazis of Germany invade France. In June, the French government moves to Vichy in the south, and several days later the Germans enter Paris in a bloodless occupation.

Fast forward to December 1941. Casablanca, a city in the French territory of Morocco. The city is under the control of the German puppet regime of Vichy. Many refugees, who aim to seek asylum in the United States, inhabit Casablanca. They're in a mad scramble to be issued visas that would allow them to board airplanes headed for Lisbon. Their sole means of escaping German territory for the U.S. is to go from here to Lisbon in neutral Portugal.

An American, Richard Blaine, known as "Rick," manages a nightclub in Casablanca called "Rick's Café Américain," which is a hangout for some of the refugees. In the past, Rick once smuggled weapons to help Ethiopia after the country was invaded, and his guns were used against the Fascists during the Spanish Civil War. Nowadays, however, his livelihood stems from ownership of his popular nightclub.

One day, a man called Ugarte shows up at the club. He sells large numbers of visas at high prices on the black market. He entrusts Rick with two letters of transit issued by the German government and stolen from two German diplomats.

When Rick returns to the club, the chief of the French military police for Casablanca, Renault, is there. Renault tells him that he will meet a German major, Strasser, at the club that evening.

Strasser has been dispatched to Casablanca to keep an eye on local anti-Nazi activities. Renault intends to arrest Ugarte, fingering him as the murderer of the German diplomats, as a way of impressing the German officer of his authority. Strasser eventually arrives. The arrest of Ugarte is a success, just as Renault had imaged. But Strasser's main objective is the arrest of Victor Laszlo, the leader of an anti-Nazi movement. Laszlo has been in hiding for the past several days, waiting for his chance to escape to the U.S.

Meanwhile, Laszlo shows up with his wife, Ilsa, at the club. Unaware that Ugarte has been arrested, Laszlo has come to the club wanting to buy the letters of transit. But with his plan unfilled, Laszlo is summoned to go to the police chief's office the following morning. The summons is from Renault, who is acting on the orders of Strasser in his pursuit of the resistance leader.

Ilsa, meanwhile, thinks that Sam, the club's pianist, looks a bit familiar. When she asks who the club's manager is, her face becomes flushed. Sam also can't hide his shock when he sees her enter the club. Ilsa calls out to Sam, asking him to play a song she recalls from her past. So on her request, he begins to play "As Time Goes By." When Rick hears the music, his face turns color. He spots Ilsa and his eyes open wide. Ilsa was the woman he loved so deeply back in Paris.

Rick and Ilsa had met at a Paris music hall called La Belle Aurore, where Sam worked. It's not revealed what paths the couple took until this point, yet they were closely drawn to each other. The couple had made an oath to begin new lives together after fleeing Paris during the Nazi invasion. However, their romance had ended after Ilsa disappeared without giving any reasons.

That night, Ilsa visits the club again to pay Rick a visit. She wants him to hear her story about what happened on the day they tried to escape Paris. Rick, although shaking with joy over the reunion, coldly thrusts her away. He is torn; although he can't forgive her, he is also passionate about reconciling with her.

Laszlo visits the police chief's office the next morning as promised. Strasser offers him a deal: if he discloses the whereabouts of the leaders of other underground groups, then he might be able to obtain a visa for him. Laszlo is hit by the keen realization that getting out Casablanca and asylum elsewhere for both him and Ilsa won't be easy.

Around this time, Rick subjected to a house search as soldiers, on Strasser's orders, patrol the town to locate the letters of transit. Laszlo appears at the scene. Laszlo has heard from Ferrari, manager of another nightclub, that Rick seems to be in possession of the letters, holding them on the behalf of Ugarte. Laszlo asks Rick whether he would be willing to hand the letters over to him, giving a passionate explanation that he needs to get asylum in order to assist many other people. Rick is obstinate and refuses. Ilsa, having found out that the discussions between Rick and Laszlo have ended in failure, works up the courage to go back to the nightclub.

Ilsa begs desperately in her appeal to get the letters of transit. She wants Rick to appreciate Laszlo's position and the mission he's burdened with. However, Rick doesn't budge. Ilsa ponders the situation before finally pointing a gun at him. Rick is unmoved and declares that he wouldn't mind so much if he were shot. Hearing this, Ilsa suddenly declares that for all this time, she was never able to take her mind off of him. As she speaks, her deepest, most inner feelings come gushing out. Rick trembles in joy, having taken back the heart of the woman he loved so much. The two confirm their shared thoughts and feelings.

Meanwhile, Laszlo escapes to Rick's nightclub while being pursued by the police. He asks Rick to take Ilsa out of Casablanca, to somewhere safe. He believes that at least he can save Ilsa. Two men love the same woman. This is the capriciousness of fate. In the town of Casablanca, Rick is miraculously reunited with the woman he loves. Who knows where a love, once passionately rekindled, will end up? And then Rick makes a final decision to ensure the protection of his beloved Ilsa.