With additional dialogue and lyrics by Christopher Fry, the film expands on some elements in the opera, notably giving Mrs Trapes (Athene Seyler) a larger role and adding dramatic action sequences to Macheath's escape.
The framing device is also changed: the Beggar (Hugh Griffith) is himself a prisoner in Newgate with the real Macheath, who escapes at the end under cover of the confusion created when the Beggar decides that his fictional Macheath should be reprieved.
The film also includes one of the first film performances of the comic actor Kenneth Williams.
In the 1700s, a beggar is tossed into London's Newgate jail, along with a pile of papers upon which his unfinished opera is scribbled. The beggar boasts to the other prisoners that his opera, unlike others of the day, is about a real person, the dashing highwayman Captain Macheath, who, dressed in a red coat, holds off the world with a pistol in each hand, seduces women with five notes of a tune, and generally leaps from misfortune. To the beggar's disappointment, the other prisoners point out that his hero Macheath is among them, in irons and behind bars, and Macheath, who is scheduled to be executed the next morning, admits that there is "no arguing with reality." Taking the first page of the opera, Macheath begins singing, and the beggar, encouraged by Macheath's good voice, urges him to continue, until the following story, the beggar's opera, is sung for the prison inmates:
While riding to London, feeling merry and free, Macheath robs a carriage, and steals a kiss and a locket from a maiden. Later, in London, Macheath's wife, Polly Peachum, pines for him. Polly's parents, shopkeepers Mr. Peachum and his wife, are scandalized to learn from their employee Filch that Polly has secretly married the highwayman. To make the best of the situation, as they are always eager to make money, they urge her to lure Macheath into a trap and collect the reward for his capture.
Meanwhile, outside of town, Macheath encounters a carriage ridden by Newgate's jailor Mr. Lockit, Lockit's daughter Lucy and Mrs. Trapes, whom Lockit is wooing. Lucy, who met Macheath when he was once imprisoned, scolds him for taking her virtue without making good on his promise to wed. When Macheath rides off, Mrs. Trapes suggests that Lucy betray him for the reward and give the money to her father.
Later, during a tryst in a hayloft, Polly warns Macheath that her parents are mounting an ambush. Macheath escapes with Polly's help after a swashbuckling fight, then hides in a back room of a tavern, where he is unable to resist socializing with the prostitutes, whom he considers friends. However, prostitute Jenny Diver has been bribed by Peachum and Lockit to betray him, and with the help of her colleagues, Macheath is soon captured.
From his jail cell, Macheath urges Lucy to steal the jail keys and set him free, promising to marry her in return, but then Polly shows up and he is forced to introduce the women to each other. During the night, Lucy steals the keys and releases him, but later Polly sneaks back and, finding Macheath gone from the cell, screams in anguish without thinking, thus drawing attention to his escape. Meanwhile, Macheath disguises himself in the stolen cape and gloves of a lord and slips into a gaming house to avoid making good his promise to unite with Lucy. However, the proprietor recognizes the cape and alerts Lockit and Peachum about the impostor wearing it. Back at the jail, Polly is accused of freeing Macheath and is locked in Lucy's room, where Lucy, after losing track of Macheath, attempts to drug her. When they hear the recaptured Macheath being returned to prison, Lucy and Polly proceed to Macheath's cell and demand that he choose between them. He refuses, as he will soon be hanged and sees no reason to disappoint either of them.
The next morning, riding atop his coffin as it is carted through the streets to the gallows, Macheath waves farewell to the friendly crowd that has gathered to see him off. At the gallows, after kissing both Lucy and Polly goodbye, Macheath is blindfolded and awaits his fate, and the opera comes to its incomplete end.
The real Macheath, who is still in the jail, protests that he should not have to hang twice. After pondering the complaint, the beggar agrees and yells for Macheath's reprieve. The rest of the prisoners join in the chant and mob the turnkey, who comes to investigate the ruckus, allowing Macheath to escape. The highwayman steals a horse from the cart containing his coffin and when safely out of London, sings that his freedom has been returned because of a beggar's opera.
Olivier received a fee of £50,000, £30,000 of which he deferred because he was interested in working with Peter Book. While the film was being shot, producer Herbert Wilcox was directing another film, Laughing Anne. Wilcox later wrote that during the film "Larry and I were in complete harmony but we could not get to first base with Peter." He claims Olivier and he constantly offered Brook practical suggestions which were ignored. Olivier was injured during filming performing a stunt. This caused insurance dramas and Wilcox had to pay £31,000 out of his own pocket.Wilcox's fee was £50,000, £30,000 of which was deferred. Alex Korda provided finance for foreign rights.
The film was sold to Jack Warner for $700,000 - who bought it without seeing it - so Korda made a profit but Olivier and Wilcox did not receive their deferred payment.