Trainspotting opens on Renton and Spud running down Princes Street, a major retail area in downtown Edinburgh, Scotland, pursued by store security guards. As stolen items drop from his pockets, Renton’s voice-over begins to deliver a monologue that satirizes what modern, Western society considers the ‘perfect life.’ As he continues this opening monologue, shots of a soccer match introduce his friends and some of their characteristics: con man Simon "Sick Boy" Williamson, good-natured and dim Daniel "Spud" Murphy, athletic Tommy Mackenzie, and psychopathic Francis Begbie. As Renton’s narration continues, we learn that he is addicted to heroin, as are Spud, Sick Boy, and Allison, another friend who has a baby. Begbie and Tommy do not touch heroin, and try to tell their friends to stop using drugs. We are also introduced to some more peripheral members of the friend group: Lizzie (Tommy’s girlfriend), Gail (Spud’s girlfriend), Swanney (their drug dealer), and Gav.
Renton decides to quit heroin, though it is implied he has tried before, and follows a withdrawal program that Sick Boy devised. Renton purchases opium rectal suppositories from Mikey Forrester, a secondary dealer after Swanney “Mother Superior,” to ease the transition to benzodiazepine use while withdrawing. His last hit wears off before the suppositories have time to melt, triggering a violent episode of diarrhea during which he loses the suppositories into “The Worst Toilet in Scotland,” and surreally dives into the toilet to try to recover them. Renton locks himself in his room to endure withdrawal. When he returns to the outside world and is still trying to stay clean, it turns out that Sick Boy has also decided to quit heroin, likely in order to cheapen Renton’s struggles in breaking addiction.
Renton, now sober, has more time for non-drug-related activities: he goes to the park with Sick Boy to shoot BB pellets at unsuspecting park-goers and helps Spud fail a job interview, but not badly enough to arouse suspicion at the unemployment office. When the whole gang is out at a pub, we are shown Begbie’s violent side—he intentionally starts a massive brawl by throwing a glass off of a balcony onto the crowd below. Renton criticizes Tommy for being unable to lie or cheat, and steals a homemade porno of him and Lizzie from Tommy’s video collection.
Renton finds his sex drive has returned and goes to a club with his friends, where he meets a young woman called Diane. They leave together, go to Diane’s apartment, and have sex. Renton stays the night on a couch, and is horrified the following morning when he discovers that Diane is actually a fifteen-year-old high school student. He tries to put the incident behind him but Diane has a different idea—she threatens to tell the police that they had sex if he does not stay in touch with her. Meanwhile, Tommy and Spud also have a terrible night: Tommy’s girlfriend freaks out when she finds out that he lost their porno and Spud gets too drunk, passes out, and defecates in Gail’s bed.
Renton, Spud, and Sick Boy start to use heroin again, stealing drugs, equipment, and cash to support their habit. Because his girlfriend has just dumped him (after losing the video that Renton actually stole), Tommy asks Renton if he can try heroin too. It is implied that Renton gives in and helps Tommy buy drugs. The group's drug-induced stupor is sharply interrupted one day when Allison finds that her young daughter Dawn has died of neglect. They are all horrified but Sick Boy is hit especially hard, as it is implied that he is Dawn's father.
Renton and Spud are caught shoplifting, and it turns out that this event is the same one that initiated the chase scene at the start of the film. They are both arrested, but Spud is given a six-month prison sentence and Renton avoids punishment by entering a methadone program for opiod withdrawal. Despite support from his family, Renton is desperate for another hit. He sneaks off to Swanney’s apartment, where he almost dies of an overdose. Swanney puts him in a taxi and sends him to the hospital. Renton's parents take him home, when he recovers, and they lock him in his childhood bedroom to force him to go through withdrawal where they can monitor him. As his symptoms become more severe he has a series of nightmarish hallucinations that remind him of the mistakes he has made: he sees Diane sitting on his bed singing, Allison's dead daughter crawling on the ceiling, Spud with chains around his ankles, Tommy looking sick and weak because of his new heroin addiction, and an imagined television game show where the host asks his parents detailed questions about HIV.
When he comes out of withdrawal his parents tell him he needs to get tested for HIV. Despite years of sharing needles with fellow addicts, he tests negative. It is implied earlier in the film that this may be due to the fact that Renton often cooked up the heroin for his friends and took the first hit, further implicating him as a cause of pain to others. Renton visits Tommy, who has become addicted to heroin and is HIV-positive. Diane visits Renton to ask if he has been tested, and when he tells her that he is negative, she invites herself into his apartment. They have sex again, and she convinces him to make a change in his life. Renton moves to London and takes a job as a letting agent with a real-estate company. He begins to enjoy his sober, drug-free life, and starts saving up money while maintaining correspondence with Diane.
Begbie and Sick-Boy show up at Renton's studio apartment and move in, unannounced. Begbie has committed an armed robbery and is hiding from the police, and Sick-Boy has become a pimp and a drug dealer, and claims to be trying to establish contacts in London. They begin to make Renton’s life miserable again. He moves them into an apartment that the company has been unable to rent to anyone, and Renton’s boss catches them. The three of them travel back to Edinburgh together.
Back in Edinburgh, Tommy has passed away from complications related to his HIV. Spud has been released from prison, and the whole gang comes back together to attend Tommy’s funeral. After the funeral, Sick Boy tells Renton about a lucrative heroin deal that the group plans to carry out, but he needs Renton to provide half of the £4,000 needed to buy the drugs. Renton initially refuses but eventually gives in. It turns out that the group also needs him to test a sample of the heroin to make sure it is good. The four travel to London and sell the heroin to a dealer for £16,000.
During their celebration at a pub in London, Renton suggests to Spud that they steal Begbie’s and Sick Boy’s share of the money and run, but Spud is hesitant. Begbie slashes a man with a broken glass and beats him up for accidentally spilling a beer on him. When Spud tries to stop Begbie, Begbie accidentally slashes Spud’s hand with his knife. As the others are still sleeping the following morning, Renton quietly takes the money. Spud sees him leave but says nothing to the others. Begbie wakes up, destroys their hotel room in violent rage, and gets arrested while Spud and Sick Boy flee the scene. Renton’s voice-over tells the audience that he plans to live a stable, ordinary life, echoing his “choose life” monologue from the opening sequence. He leaves Spud his share of the money in a lockbox because he feels bad for Spud, who never tried to hurt anyone.