Casablanca is an exploration of the universal themes of love and sacrifice, but when the film was released in 1942, audiences viewed it as a political allegory about World War II. The film is set in December 1941, the month in which the Japanese attacked Pearl Harbor. That attack changed the course of American history, awakening the nation from political neutrality and thrusting it into the midst of World War II. Casablanca tells the story of a similar, though much smaller, awakening. At the beginning of the film, Rick is a cynical bar owner in the Moroccan city of Casablanca who drinks only by himself and doesn't care about politics. By the end of the film, he has become a self-sacrificing idealist, committed to the anti-Nazi war effort. The event that prompts this change in Rick is the appearance of Ilsa, his old flame, in Casablanca. Ilsa's arrival is unexpected and devastating, and it hits Rick just as hard as the Japanese sneak attack on Pearl Harbor hit America. Once Rick overcomes the initial pain, his moral sense is reignited. He doesn't get to live happily ever after with Ilsa, but he accepts the necessity of his sacrifice and the heartbreak that accompanies it. If Ilsa hadn't reappeared in his life, Rick would still be stuck in a life of bitterness in Casablanca. Instead, he is reawakened to the world and to himself.

The film also tells the story of another transformation, that of the local French commander of Casablanca, Captain Louis Renault. Louis begins the film as a pro-Vichy Nazi-appeaser but winds up a committed partisan of free France. American Rick and European Louis look out for each other's interests throughout the film, but only at the end does their relationship become anything more than the self-serving alliance of two cynics. "Louis, I think this is the beginning of a beautiful friendship," Rick says in the film's last line, thereby cementing not only their friendship, but also the maturing anti-Nazi coalition their friendship symbolizes. In the film's political allegory, Rick and Louis's relationship suggests the U.S.'s relationship to its allies in World War II.

While Rick and Louis find their political identity only at the end of the film, a number of other characters know where they stand from the beginning. In large part, this certainty has to do with their nationality. Victor Laszlo, the famous anti-Nazi writer, is Czech, and since Nazi Germany's first expansionist move was against Czechoslovakia, the Czechs knew of Nazi evil before anyone else. Similarly, all of the characters who support Casablanca's anti-Nazi underground are from nations that resisted German rule. They include the Norwegians Berger and Ilsa and the Russian bartender Sacha. On the other hand, many of the film's unseemly characters, such as the criminal Ugarte, the black market schemer Signor Ferrari, and the bumbling officer Tonelli, are Italian, and Italy was an ally of Germany during the war. While the Italians may not be worthy of admiration, none are as cruel and ruthless as Major Strasser, the film's archetypal Nazi villain.