The Captain takes an extended visit to a lady friend, Baroness Elsa Schroeder, a wealthy socialite from Vienna, who accompanies him on his return. While taking a boat ride on the lake, the children become excited at their father's return and cause the boat to capsize, precipitating an argument between the Captain and Maria. The Captain is displeased with the activities she has arranged for the children and furiously orders her to return to the abbey. However, the Captain later relents when he hears the children singing for the Baroness, and apologizes to Maria and asks her to stay. Max Detweiler—a mutual friend of the Captain and the Baroness—who is searching for a novel musical act to enter into the upcoming Salzburg Festival, is impressed by the children's singing, but the Captain forbids their participation.
At a banquet the Captain has organized in honor of Baroness Schroeder, eleven-year-old Kurt watches the guests dancing the Laendler and he asks Maria to teach him the steps. When the Captain sees Maria dancing in the moonlight, he cuts in and partners her in a graceful performance, culminating in a close embrace; Maria breaks away and blushes, confused about her feelings. At the end of the evening, the Baroness, noticing the Captain's attraction to Maria, convinces her to return to the abbey. Back at the abbey, Maria keeps herself in seclusion until Mother Abbess persuades her to return to the von Trapp family. When she discovers that the Captain is now engaged to the Baroness, she agrees to stay until they find a replacement governess. Realizing that he is in love with Maria, the Captain breaks off the engagement, and they subsequently declare their love for each other; soon after, the two are married in an elaborate ceremony.
While the Captain and Maria are on their honeymoon in Paris, Max enters the children in the Salzburg Music Festival against their father's wishes. Austria is annexed into the Third Reich in the Anschluss, and upon their return the Captain is informed by telegram that he must report as soon as possible to the German Naval Headquarters in Bremerhaven to accept a commission in the German Navy. Strongly opposed to Nazism, the Captain tells his family they must leave Austria. As the von Trapp family attempts to leave during the night, they are stopped by Nazi guards outside their estate. They lie to the guards claiming they are performing in the Salzburg Festival, so Hans Zeller, the recently appointed Nazi Gauleiter, agrees to accompany them to the hall, but insists that the Captain depart for Germany immediately after the performance. The family takes part in the contest and slip away during their final number, seeking shelter from the patrolling guards at the abbey cemetery. They are discovered hiding by Rolfe (a former messenger boy enamoured of the Captain's sixteen-year-old daughter, Liesl, but now a proud Nazi) who threatens to shoot the Captain. The Captain is able to disarm the boy and tries to persuade him to escape with them, but Rolfe calls for assistance. After the family escapes in a waiting car, the Nazis try to pursue, but their cars fail to start, having being sabotaged by the nuns. The von Trapp family hike over the Alps into Switzerland and to freedom.