In 1942 during World War II, Wing Commander Max Vatan, a Royal Canadian Air Force pilot serving on intelligence duties, travels to Casablanca in Morocco to assassinate the German ambassador. He is partnered with a French Resistance fighter named Marianne Beauséjour, who had escaped from France after her resistance group was compromised and killed.
The two pose as a married couple and grow close, despite agreeing that in their line of work feelings can get people killed. Marianne, who is trusted by the Germans, secures Max an invitation to the party where they plan to conduct the assassination. On the day itself, they have sex inside a car in the middle of a desert sandstorm, knowing that they might not survive. However, the mission goes well and they both escape. Max asks Marianne to come with him to London and be his wife. The two get married, settle down in Hampstead, and have a baby girl named Anna, who was born during a bombing raid.
A year later, Max learns from the Special Operations Executive that Marianne is suspected of being a German spy, having adopted her identity after the real Marianne was killed in France. In order to test their suspicions, SOE run a "blue dye" operation: Max is ordered to write down a piece of false intelligence at home, where Marianne can find it. If the information is picked up from intercepted German transmissions,
Max must personally execute her, or be hanged for high treason. Max is told otherwise to act normally.
Defying orders, Max visits a former colleague named Guy Sangster who knew Marianne but, blind from a wartime injury, cannot confirm her identity. He reveals that the resistance fighter Paul Delamare worked with Marianne in France and would be able to identify her. Max seeks out a young pilot named Adam Hunter, gives him a photograph and instructs him to ask Delamare whether she really is Marianne. Max's commanding officer Frank Heslop informs him that Hunter was killed while waiting on the ground for the answer. Max also hears that this whole operation might be a test, before he is given a vital job in the run-up to D-Day.
Max takes the place of a Lysander pilot and flies to France to meet with Delamare, who is being held at the local police station. Max and the resistance break into the jail. Delamare is drunk, but remembers that Marianne was a beautiful pianist.
Back in England, Max takes Marianne to a local pub and demands she play the piano. Marianne cannot. She admits she is a spy and forwarded the "blue dye" message which Max left in plain view. She claims her feelings for Max are genuine and that she and her child were being threatened by German spies in London, including the woman who lives around the corner and often looks after Anna.
Max, unwilling to kill his wife, tells her they need to leave before the SOE catches them. He kills Marianne's handlers and tries to flee the country via airplane, but Heslop intercepts them before they can escape. Marianne tells Max that she loves him, asks him to take care of Anna, then shoots herself. Heslop orders the soldiers present to report that Max executed Marianne as per his orders, so that Max himself will not be punished.
After the war, Max moves to the ranch in Medicine Hat, Alberta, Canada, that was always his ambition, and raises Anna. The film ends with Marianne reading the letter that she had earlier written to her daughter, anticipating that one day her real identity would be uncovered.