In Salzburg, Austria in 1938, Maria is a free-spirited young postulant at Nonnberg Abbey. Her love of music and the mountains, her youthful enthusiasm and imagination, and her lack of discipline cause some concern among the nuns. The Mother Abbess, believing Maria would be happier outside the abbey, sends her to the villa of retired naval officer Captain Georg von Trapp to be governess to his seven children. The Captain has been raising his children using strict military discipline following the death of his wife. Although the children misbehave at first, Maria responds with kindness and patience, and soon the children come to trust and respect her. Liesl, the oldest, is won over after Maria protects her from discovery when she is nearly caught sneaking back into the house after meeting with Rolfe, a messenger boy she is in love with.
While the Captain is away in Vienna, Maria makes play clothes for the children and takes them around Salzburg and the surrounding mountains, and teaches them how to sing. When the Captain returns to the villa with the wealthy socialite Baroness Elsa Schraeder and their mutual friend, the musical agent Max Detweiler, they are greeted by Maria and the children returning from a boat ride on the lake that concludes when their boat overturns. Displeased by his children’s clothes and activities, and Maria’s impassioned appeal that he get closer to his children, the Captain orders her to return to the abbey. Just then he hears singing coming from inside the house and is astonished to see his children singing for the Baroness. The Captain joins his children, singing for the first time in years. Afterwards, he apologizes to Maria and asks her to stay.
Impressed by the children’s singing, Max proposes he enter them in the upcoming Salzburg Festival, but the suggestion is immediately rejected by the Captain as he is opposed to his children singing in public. He does agree, however, to organize a grand party at the villa. The night of the party, while guests in formal attire waltz in the ballroom, Maria and the children look on from the garden terrace. When the Captain notices Maria teaching Kurt the traditional Ländler folk dance, he cuts in and dances with Maria in a graceful performance, culminating in a close embrace. Confused about her feelings, Maria blushes and breaks away. Later, the Baroness, who noticed the Captain’s attraction to Maria, convinces Maria that she must return to the abbey. Back at the abbey, when Mother Abbess learns that Maria has stayed in seclusion to avoid her feelings for the Captain, she encourages her to return to the villa to look for her life. After Maria returns to the villa, she learns about the Captain’s engagement to the Baroness and agrees to stay until they find a replacement governess. The Captain’s feelings for Maria, however, have not changed, and after breaking off his engagement, the Captain marries Maria.
While the Captain and Maria are on their honeymoon, Max enters the children in the Salzburg Festival against their father’s wishes. When they learn that Austria has been annexed by the Third Reich in the Anschluss, the couple return to their home, where a telegram awaits informing the Captain that he must report to the German Naval base at Bremerhaven to accept a commission in the German Navy. Strongly opposed to the Nazis and the Anschluss, the Captain tells his family they must leave Austria immediately for Switzerland. Many of the Von Trapps’ friends are prepared to accept the new regime, including Rolfe, who has joined the Hitler Youth. That night, as the von Trapp family attempt to leave, they are stopped by a group of Brownshirts waiting outside the villa. When questioned by Gauleiter Hans Zeller, the Captain maintains they are headed to the Salzburg Festival to perform. Zeller insists on escorting them to the festival, after which his men will accompany the Captain to Bremerhaven.
Later that night at the festival, during their final number, the von Trapp family slip away and seek shelter at the nearby abbey, where the nuns hide them in the cemetery crypt. Brownshirts soon arrive and search the abbey, and the family is discovered by Rolfe. Upon seeing Liesl, he hesitates to raise the alarm (long enough to allow the family time to flee), and the family is able to escape using the caretaker’s car. When the soldiers attempt to pursue, they discover their cars will not start as two nuns have removed parts of the engines. The next morning, after driving to the Swiss border, the von Trapp family make their way on foot across the Swiss Alps into Switzerland.