The film begins in medias res with an armed gang chasing after an escaped chicken in a favela called the Cidade de Deus (“City of God”). The chicken stops between the gang and the narrator, a young man nicknamed Rocket (“Buscapé”).
The film flashes back to the 1960s where the favela is shown as a newly built housing project with little resources. Three impoverished, amateur thieves known as the “Tender Trio” – Shaggy (“Cabeleira”), Clipper (“Alicate”), and Rocket’s older brother, Goose (“Marreco”) – rob business owners and share the money with the community who, in turn, hide them from the police. Li’l Dice (Dadinho), a young boy, convinces them to hold up a motel and rob its occupants. The gang resolves not to kill anyone and tells Li’l Dice to serve as a lookout. Instead, Li’l Dice guns down the motel occupants after falsely warning the trio that the police are coming. The massacre is brought to the police’s attention, forcing the trio to split up: Clipper joins the church, Shaggy is shot by the police while trying to escape the favela, and Goose is shot by Li’l Dice after taking his money while Li’l Dice’s friend Benny (Bené), Shaggy’s brother, watches.
In the 1970s, the favela has been transformed into an urban jungle. Rocket has joined a group of young hippies. He enjoys photography and likes one girl, Angélica, but his attempt to get close to her is ruined by a gang of petty criminal kids known as “The Runts”. Li’l Dice, who now calls himself “Li’l Zé” (“Zé Pequeno”), has established a drug empire with Benny by eliminating all of the competition, except for Carrot, who is a good friend of Benny’s. Li’l Zé takes over ‘the apartment’, a known drug distribution center, and forces Carrot’s manager Blacky (“Neguinho”) to work for him instead. Coincidentally, Rocket visits the apartment to get some drugs off Blacky for Angélica during the apartment raid. Through narration, Rocket momentarily considers attempting to kill Li’l Zé to avenge his brother but decides against it. He is let go after Benny tells Li’l Zé that Rocket is Goose’s brother.
Sometime later, a relative peace comes over the City of God under the reign of Li’l Zé, who manages to avoid police attention. Benny decides to branch out of the drug dealer crowd and befriends Tiago, Angélica’s ex-boyfriend, who introduces him to his (and Rocket’s) friend group; Benny and Angélica begin dating. Together, they decide to leave the City and the drug trade. During Benny’s farewell party, Zé and Benny get into an argument; Blacky accidentally kills Benny while trying to shoot Li’l Zé. Benny’s death leaves Li’l Zé unchecked. Carrot kills Blacky for endangering his life. Li’l Zé and a group of his soldiers start to make their way to Carrot’s hideout with the intention of killing him. On the way, Zé follows a girl who dismissed his advances at Benny’s party; he beats up her boyfriend, a peaceful man named Knockout Ned (Mané Galinha), and rapes her. After Ned’s brother stabs Li’l Zé, his gang retaliates by shooting into his house, killing his brother and uncle in the process. A gang war breaks out between Carrot and Li’l Zé; a vengeful Ned sides with Carrot.
The war is still ongoing a year later, in 1981, the origin forgotten. Both sides enlist more “soldiers” and Li’l Zé gives the Runts weapons. One day, Li’l Zé has Rocket take photos of him and his gang. A reporter publishes the photos, a major scoop since nobody is able to safely enter the City of God anymore. Rocket believes his life is endangered, as he thinks Li’l Zé will kill him for publishing the photo of him and his gang. The reporter takes Rocket in for the night, and he loses his virginity to her. Unbeknownst to him, Li’l Zé, jealous of Ned’s media fame, is pleased with the photos and with his own increased notoriety.
Rocket returns to the City for more photographs, bringing the film back to its opening scene. Confronted by the gang, Rocket is surprised that Zé asks him to take pictures, but as he prepares to take the photo, the police arrive and then drive off when Carrot’s gang arrives. In the ensuing gunfight, Ned is killed by a boy who has infiltrated his gang to avenge his father, a policeman whom Ned has shot. The police capture Li’l Zé and Carrot and plan to show Carrot off to the media. Since Li’l Zé has been bribing the police, they take all of Li’l Zé’s money and let him go, but Rocket secretly photographs the scene. The Runts murder Zé to avenge the Runt murdered at the behest of Zé; they intend to run his criminal enterprise themselves.
Rocket contemplates whether to publish the photo of the cops, exposing corruption and becoming famous, or the photo of Li’l Zé’s dead body, which will get him an internship at the newspaper. He decides on the latter and the film ends with the Runts walking around the City of God, making a hit list of the dealers they plan to kill to take over the drug business, including the Red Brigade.