In a futuristic Britain, Alex DeLarge is the leader of a gang of "droogs", Georgie, Dim and Pete. One night, after getting intoxicated on drug-laden "milk-plus", they engage in an evening of "ultra-violence", which includes a fight with a rival gang led by Billyboy. They drive to the country home of writer F. Alexander and beat him to the point of crippling him for life. Alex then rapes Alexander's wife while singing "Singin' in the Rain". The next day, while truant from school, Alex is approached by his probation officer Mr P.R. Deltoid, who is aware of Alex's activities and cautions him.
Alex's droogs express discontent with petty crime and want more equality and high yield thefts, but Alex asserts his authority by attacking them. Later, Alex invades the home of a wealthy "cat-lady" and bludgeons her with a phallic sculpture while his droogs remain outside. On hearing sirens, Alex tries to flee but Dim smashes a bottle on his face, stunning him and leaving him to be arrested by the police. With Alex in custody, Mr Deltoid gloats that the woman he attacked died, making Alex a murderer. He is sentenced to fourteen years in prison.
Two years into the sentence, Alex eagerly takes up an offer to be a test subject for the Minister of the Interior's new Ludovico technique, an experimental aversion therapy for rehabilitating criminals within two weeks. Alex is strapped to a chair, his eyes are clamped open and he is injected with drugs. He is then forced to watch films of sex and violence, some of which are accompanied by the music of his favourite composer, Ludwig van Beethoven. Alex becomes nauseated by the films and, fearing the technique will make him sick upon hearing Beethoven, begs for an end to the treatment.
Two weeks later, the Minister demonstrates Alex's rehabilitation to a gathering of officials. Alex is unable to fight back against an actor who taunts and attacks him and becomes ill wanting sex with a topless woman. The prison chaplain complains that Alex has been robbed of his free will; the Minister asserts that the Ludovico technique will cut crime and alleviate crowding in prisons.
Alex is let out as a free man, only to find the police have given away his possessions as compensation for his victims and his parents have let out his room. Alex encounters an elderly vagrant whom he had attacked years earlier, and the vagrant and his friends attack him. Alex is saved by two policemen but is shocked to find they are his former droogs Dim and Georgie. They drive him to the countryside, beat him up, and nearly drown him before abandoning him. Alex barely makes it to the doorstep of a nearby home before collapsing.
Alex wakes up to find himself in the home of Mr Alexander, where he is being cared for by Alexander's manservant, Julian. Mr Alexander does not recognise Alex from the previous attack but knows of Alex and the Ludovico technique from the newspapers. He sees Alex as a political weapon and prepares to present him to his colleagues. While bathing, Alex breaks into "Singin' in the Rain", causing Mr Alexander to realise that Alex was the person who assaulted him and his wife. With help from his colleagues, Mr Alexander drugs Alex and locks him in an upstairs bedroom. He then plays Beethoven's Ninth Symphony loudly from the floor below. Alex is unable to withstand the sickening pain and attempts suicide by throwing himself out the window, falling unconscious on the ground.
Alex wakes up in a hospital with broken bones. While being given a series of psychological tests, Alex finds that he no longer has aversions to violence and sex. The Minister arrives and apologises to Alex. He offers to take care of Alex and get him a job in return for his cooperation with his election campaign and public relations counter-offensive. As a sign of goodwill, the Minister brings in a stereo system playing Beethoven's Ninth. Alex then contemplates violence and has vivid thoughts of having sex with a woman in front of an approving crowd, and thinks to himself, "I was cured, all right!"