1938, Salzburg, Austria; Maria is a young postulant at Nonnberg Abbey, but her request to become a member of the community of nuns is causing some concern, because she is seen as too flighty for the abbey. The Mother Abbess believes she would be better suited to life outside the abbey and sends her to take up the position of governess to the children of retired naval office Georg von Trapp. The Captain has been raising his children in the style of the military but Maria finds that they respond better to love, kindness and gentle words.
The Captain takes a trip to Vienna; Maria takes the opportunity to teach the children to sing, and also shows them around Salzburg and the mountains surrounding them. When the Captain returns with his companion, wealthy socialite Baroness Elsa Schrader, and their friend Max Detweiler, a theatrical agent, they find the children disheveled and over-excited after coming home from a boat ride. He orders Maria back to the abbey, ignoring her plea that he try to get closer to his children. When he hears singing coming from the house, he hurries to find the children singing for the Baroness, and for the first time in years, since before the death of his wife, he joins them. Realizing that it is Maria who has taught them to sing, he apologizes to her and asks her to stay on at the villa.
Max is rather impressed with the singing and wants to enter the children in the Salzburg Festival, but the Captain does not want his children to sing in public and immediately quashes the idea. He does agree to a compromise, though; he will organize a party at the villa where perhaps the children will be allowed to sing. The children and Maria watch the festivities from the garden terrace, but when the Captain notices Maria teaching his son Kurt how to dance, he cuts in, and dances the traditional Landler folk dance with her, ending with an embrace. Maria pulls away, suddenly confused by her feelings. Later, the Baroness, who can see that the Captain is attracted to Maria, tells her that she should return to the abbey as soon as possible.
Mother Abbess learns that Maria has confined herself to the abbey to try to put her feelings for the Captain aside. She encourages her to go back to the villa so that she can carve out a life for herself, but when she returns she discovers that the Captain and the Baroness have become engaged. She agrees to stay on until another governess can be found for the children. This is not what the Captain wants; his feelings for Maria have not diminished. He breaks off his engagement, and marries Maria, who admits that her feelings for him are the same.
Max takes the opportunity to enter the children in the Salzburg Festival whilst the Captain and Maria are on their honeymoon, but their trip is cut short by the news that the German Third Reich have annexed Austria; the Captain is summoned to the German naval base at Bremerhaven to accept a commission to the German Navy. The Captain is opposed to the Nazi regime and their annexation of Austria. He plans an escape to Switzerland for the family but he finds that many of his friends are only too happy to accept Nazi rule in their country, particularly Liesl's boyfriend, Rolfe, who has already joined the Hitler Youth. It will not be easy for them to find allies, or friends, who will help them escape.
As they try to leave the villa that night, they are apprehended by a group of Brownshirts, Hitler's military police, who question the Captain about their plans. He tells them that they are not trying to escape. They are actually heading to the Salzburg Festival where the children will be performing. Hans Zeller, the man in charge, tells them that they can go to the Festival, but that he will accompany them, and afterwards his men will accompany the Captain to Bremerhaven.
The von Trapp family are an enormous success at the Festival. They perform their final number, and whilst the applause is still ringing in their ears, they slip away, as the Festival judges are deliberating the performances they have seen. They have won the Festival, but as they are announced, they are nowhere to be seen. They seek shelter at the abbey where the nuns hide them in the cemetery crypt. The brownshirts hunt all over the abbey unsuccessfully, but their hiding place is discovered by Rolfe, who hesitates when he sees Liesl, giving them just enough time to escape. They find the car belonging to the abbey caretaker and use it to flee; nobody can drive after them, as two nuns have removed vital parts of the engines of their vehicles whilst they have been combing the abbey for the von Trapps.
The family drive all the way to the Swiss border, leaving the car before they get to the checkpoint, and crossing into Switzerland over the Alps, on foot.