Alex, living in near-future England, leads his gang on nightly orgies of opportunistic, random violence; which he refers to as "ultraviolence". Alex's friends ("droogs" in the novel's Anglo-Russified slang) are Dim, a slow-witted bruiser who is the gang's muscle, Georgie, and Pete. Alex, who is quick-witted and possessing an often disconcerting sense of humour, is the leader of the group and seemingly very cultured.
The novel begins with the droogs sitting in their favourite milkbar, drinking drugged milk to hype themselves for the night's mayhem. They assault a scholar walking home from the library, stamp on a panhandling derelict, scuffle with a rival gang led by Billyboy, rob a newsagent and leave its owners unconscious, then steal a car. Joyriding in the countryside, they break into an isolated cottage and maul the young couple living there, beating the husband and raping his wife. The husband was a writer working on a book he entitled "A Clockwork Orange" - the strange name stayed with Alex for the rest of his life. Shortly after the droogs ditch the car and return to the bar, Alex reprimands Dim for some crude behavior, and Georgie, thinking Alex is over-stepping boundaries, makes his dissatisfaction with Alex's leadership clear. At home in his dreary flat, Alex plays classical music thunderously while bringing himself to climax with fantasies of even more orgiastic violence.
Alex skips school the following morning and is visited by P. R. Deltoid, a "post-corrective advisor" assigned to remediate his juvenile delinquency. Deltoid voices that he feels Alex will end up in jail shortly if he does not change his ways, but this falls upon a deaf ear. Visiting his favourite music shop, Alex meets a pair of underage girls and takes them back to his parents' flat, where he gives them alcohol and sexually assaults them while they are intoxicated.
Alex later chats with his parents, who are sceptical of his claims about having a night job, yet too intimidated to press the issue. Arriving late to meet the droogs, who have already pumped themselves up with "the old knifey moloko" (drugged milk). Georgie challenges Alex for leadership of the gang, demanding that they pull a "man-sized" job by robbing a wealthy old woman who lives alone with her cats. Alex quells the rebellion by slashing Dim's hand and fighting with Georgie, then in a show of generosity takes them to a bar for some fortifying drinks. Georgie and Dim are ready to call it a night, but Alex bullies them into proceeding with the burglary. At the woman's house, she's reluctant to open the door and calls the police. His droogs lift Alex through a second-floor window and, after a farcical struggle, he knocks the old woman unconscious. With sirens in the distance Alex flees. His droogs await him at the front door, and Dim hits Alex across the face with a bicycle chain, causing him extreme pain and temporary blindness. They leave Alex to fend for himself, and the police find and arrest him. At the police station they ask him questions about the invasion. P.R. Deltoid shows up and renounces Alex, spitting in his face and telling him that he can't intercede on his behalf any longer. Alex is later summoned from his jail cell and learns that his victim has died and he is now guilty of murder.
After enduring prison life for two years, Alex gets a job as an assistant to the prison chaplain. He feigns an interest in religion and amuses himself by reading the Bible for its lurid descriptions of "the old yahoodies (Jews) tolchocking (beating) each other" and imagining himself taking part in "the nailing-in" (the Crucifixion of Jesus). Alex learns of his ex-droog Georgie's death by an intended victim during a botched robbery. He also hears about an experimental rehabilitation programme called "the Ludovico technique", which promises that the prisoner will be released upon completion of the two-week treatment and, as a result, will not commit any crimes afterwards. The prison chaplain warns against it, arguing that moral choice is necessary to humanity — a theme introduced earlier during the home invasion scene, when Alex reads a passage from the victimised husband's work in progress.
Alex is selected to become the subject in the first full-scale trial of the Ludovico technique. The technique itself is a form of aversion therapy, in which Alex is given a drug that induces extreme nausea while being forced to watch graphically violent films for two weeks. Strapped into a seat before a large screen, Alex is forced to watch an unrelenting series of violent acts. During the sessions, Alex begins to realise that not only the violent acts but the music on the soundtrack is triggering his nausea attacks (Kubrick's film version narrows this down so that only Beethoven's Ninth Symphony has this effect.) Alex pleads with the supervising doctors to remove the music, crying that it is a sin to take away his love of music and adding that "Ludwig Van" did nothing wrong and "only made music", claiming that it was wrong to use the composer in that way, but they refuse, saying that it is for his own good and that the music may be the "punishment element". By the end of the treatment, Alex is unable to listen to his favourite classical pieces without experiencing nausea and distress.
A few weeks later, Alex is presented to an audience of prison and government officials as a successfully rehabilitated inmate and potential member of society. Alex's conditioning makes him unable to defend himself against a pummelling bully and cripples him with nausea when the sight of a scantily clad woman arouses his predatory sexual impulses. The prison chaplain rises to denounce the treatment and accuses the state of stripping Alex of the ability to choose good over evil. "Padre, these are subtleties", a government official replies. "The point is that it works". And so Alex is released into society.
The Ludovico treatment leaves him ill when he attempts violence, so he is powerless. Alex returns home joyful at the thought of starting afresh, but finds that his parents have rented out his room to a lodger named Joe, essentially "replacing" their son. Alex runs into old victims, and is powerless when they seek their revenge. Despondently wandering, Alex stops at the Korova Milk Bar and drinks synthemesc-laced milk, as opposed to his usual drencrom-laced milk. He visits the music store, but the store clerk harasses Alex by playing loud obnoxious music rather than the classical music requested, causing Alex to leave the store in a rage. Alex decides to commit suicide, yet is unable to because the technique prevents him from committing any act of violence, including against himself. In the public library, Alex is quickly recognised by the elderly scholar whom he had beaten up with his droogs in chapter one. With his friends, the scholar attacks and beats Alex. The police (summoned by the librarian) turn out to be Dim and Billyboy. Taking advantage of their positions, they take Alex to the town's edge, beat him, and leave him for dead.
Alex wanders in a daze through the countryside until he collapses at the door of an isolated cottage. Too late he realises this is the home he and his droogs invaded at the start of the book. He is taken in by F. Alexander, the husband of the woman the droogs gang-raped; Mr. Alexander doesn't recognise Alex because the droogs were wearing masks during the assault. We learn that Mrs. Alexander died of the injuries inflicted during the rape, and her husband has decided to continue "where her fragrant memory persists" despite the horrid memories. Alex has been careless with words during his time in Mr. Alexander's care, and the writer begins to suspect they have met before. Mr. Alexander recognises Alex from newspaper publicity about the behaviour modification treatment, and sees an opportunity to use him as a political weapon by turning him into a poster child for the victims of fascism.
One of Mr. Alexander's political activist friends takes Alex aside and puts the question to him bluntly: Alex, cornered, makes a non-denial denial by saying "Lord knows I've suffered". "We'll speak no more of it", the friend assures him, but later on Alex is taken to another house, locked into a room, and tormented with classical music, triggering the maddening effect of the Ludovico treatment. Driven to insanity by the music, Alex jumps from his bedroom window in an attempt to end his life.
Alex wakes up in hospital, where he learns that the government, trying to reverse the negative publicity it incurred in the wake of Alex's suicide attempt, has reversed the effects of the Ludovico treatment. Mr. Alexander has been incarcerated in a mental institution, "for his own protection and for yours," Alex is told. In return for agreeing to cooperate with the powers that be, Alex is promised a cushy job at high salary. His parents offer to take him back in, and Alex happily ponders returning to his life of violence.
In the final chapter, Alex finds himself back at the milkbar. He is half-heartedly preparing for another night of crime with a new trio of droogs, who are bemused at the discovery of a photograph of a baby in Alex's pocket. Alex watches them beat an innocent stranger walking home with a newspaper, but he doesn't get the same thrill out of it as he used to. He leaves his gang, then has a chance encounter with his old droog Pete, who has grown up and gotten married. Alex acknowledges to the reader that the reason he was carrying a photograph of a baby is because he would like a son of his own. He begins contemplating giving up crime to become a productive member of society and start a family, acknowledging on the notion that his own children could be just as destructive as he was himself, which leads us to realise that violence is childish.