Captain Roberto Nascimento (Wagner Moura) narrates the film, briefly explaining how the police and the drug lords of Rio de Janeiro cooperate with each other (policemen collect periodic bribes and drug lords are left free to operate) in the 90's.In 1997, In medias res, officer Captain Oliveira (Marcelo Valle) and his colleagues are shown driving through Morro da Babilônia towards a baile funk. Nascimento and his other colleagues are also shown in their armored car. Meanwhile, novice police officers André Matias (André Ramiro) and Neto Gouveia (Caio Junqueira) are shown riding a motorcycle at the same favela, though not with the other officers. Once they make it to a vantage point, Neto uses the telescope of a sniper rifle to check on the police team as they talk to some drug traffickers. Neto shoots one of them and provokes a deadly gunfight between police and thugs, both sides unaware of where the bullet came from, forcing Mathias and Neto to flee the scene. Nascimento leads his colleagues from BOPE, Rio Special Police Department, heading to the shootout to interfere and save the officers.Six months earlier, Nascimento and his wife Rosane (Maria Ribeiro) are shown during her pregnancy of their first child. Not wanting to be an absent father when his child is born, Nascimento decides to search for a successor for his role as a captain, since he will be promoted to Lieutenant Colonel. This coincides with an operation he will have to lead at Morro dos Prazeres in order to secure the location and clean it of drug dealers, so that Pope John Paul II can spend the night in Archbishop's home, located near the slum buildings and favelas. The operation will require daily trips into the favela filled with heavily armed drug lords, and Nascimento is initially against it, but is forced by his superiors to accept it as his last mission, due to Pope's regards and requirements which cannot be annulled.Meanwhile, Neto and Matias debut as police officers. Both are honest and try to stay out of corruption, but are soon disillusioned by their corrupt superiors. While Neto starts at the police auto mechanic shop as a supervisor, being in charge of the mechanics who are fixing run-down police cars and bikes with parts from newer cars, Matias is responsible for repairing and listening to the police dispatchers and registering and filing every complaint in his small archive office with two other officers. Both share a small apartment in Rio and are long-time friends and flatmates.Besides working at the local police, Matias is a Law student at "the best new Law university of Rio", according to Nascimento, where his classmates are shown as well-off young adults that tend to see the police as a repressive unit, while several others are selling marijuana around the campus. He soon befriends Roberta (Fernanda de Freitas), Edu (Paulo Viela) and Maria (Fernanda Machado) (whom he later dates). All three work at an NGO that takes care of poor children from a local favela. Roberta dates Rodrigues, who helps Maria administrate the organization, besides representing a senator who sponsors the NGO. All of them smoke marijuana regularly, with Edu being a salesman at his university for Baiano (Fábio Lago), the local drug lord, who allows the NGO to operate as long as it doesn't interfere with his business or bring police attention. None of the students or dealers are aware of Matias's police career as he keeps it a secret.Neto is soon tired of working at the mechanic, but fails to be transferred to another department. By riding with his superior Captain Fabio (Milhem Cortaz), he learns about corruption schemes adopted by police officers commonly, owners of small establishments pay periodic bribes to the police in exchange for their presence in front of their places, so they are safer. Another scheme, learned by Matias, is the relocation of dead bodies to other battalion's areas, so that one's criminal statistics will artificially decrease and leave less work to the department charged to the battalion, which Matias learns the hard way when his superiors rage at him for filling their department with files they are too lazy to solve. Also, because the local government had no budget to pay tow trucks, they decided to hire private tows and pay for every towed car - towing vehicles had since become a lucrative activity and corrupt officers are shown to own tow trucks.Wishing to raise some money to fix many police cars at once, Neto comes up with a plan to steal the bribes Oliveira collects periodically from the drug lords and asks Matias and Fabio to help him. Fabio declines, since he will not have a share in it. The duo succeeds in stealing the money, but Oliveira believes Fabio ordered them to do it and drags him to a baile funk in Babilônia, where he plans to give him over to the gang so they can kill him. However, while Neto and Matias (demoted to cooks at the kitchen for being suspects) confront him, he tells them about the funk party, hinting that he is going to be killed. Neto and Matias follow them and arrive at the vantage point to protect Fabio. When one of the dealers touches his gun, Neto opens fire killing the dealer and provoking a gunfight between the police and dealers. Fabio takes cover behind a bar and engages in a shootout with Olivera's men while his two protectors fight some of the heavily-armed dealers with only two pistols, a rifle and a sub-machine gun, but quickly run out of ammo.Meanwhile, Nascimento is confronted by a woman claiming the body of her son, who was killed by drug lords after being forced to confess by Nascimento, who was then released knowingly of the danger. Feeling guilty and thinking of his upcoming child, Nascimento gathers some officers and goes after the body. Just as they are torturing a member of the boy's gang into telling them where they have left him, Nascimento is informed of the situation at Babilônia and ordered to interfere. After rescuing the trapped officers at Babilônia, Nascimento meets Matias and Neto and orders them to start loading up bodies, and they are photographed by the press in the process lifting the body of a local drug lord. They also learn that BOPE's training program is about to begin and they soon apply for it. Both decide to give it a try and Fabio joins them to escape from Oliveira. Meanwhile, Rafael, Nascimento's son, is born.Just when the NGO program is about to start, Maria and her friends are confronted by Baiano, who found out about Matias's job as an officer after seeing his picture at a newspaper carrying the body of the drug lord - whom he reveals to have been his friend and a partner from another neighborhood with whom has been dealing drugs. Baiano threatens them to get rid of Matias and then leaves.Meanwhile, BOPE's training program takes place over the course of a few weeks in the jungles of Brazil, and proves a tough challenge and all enrolled officers are subjected to severe physical and psychological punishments and are trained under extreme pressure "in order to eliminate the weak and, mainly, punish the corrupt", as Nascimento explains, as the goal is to eliminate all the corrupt and mentally weak officers and only keep the honest and tough ones. Many officers quit the program, including Fabio after he gets foot fungus, but Neto and Matias reach the final level, where they are brought into Nascimento's final operation. Neto also gets a BOPE tattoo.Matias, now rejected by Maria and her friends, confronts Edu and orders him to arrange a meeting with Romerito, a boy with eyesight problems he met at the NGO and is now willing to provide him with a pair of glasses. Because Matias is aware that he will be killed once inside the slum, he blackmails Edu into arranging the meeting at the base of the slum. However, Neto informs Matias that he arranged a job interview for the same day and hour and offers to go in his place to bring Romerito the glasses.Edu reveals to Baiano that he had been threatened by Matias, and the drug lord decides to take revenge on Matias for getting his friend killed, as well as interrupting his operations. After giving Romerito his glasses, Neto is taken down by Baiano and his men. Before finishing him off, Baiano sees Neto's tattoo and realizes he is a BOPE officer. Knowing that killing such an officer will invoke a heated search for himself, he kidnaps Roberta and Rodrigues and murders them, shooting Roberta in the head and necklacing Rodrigues, as a punishment for bringing a BOPE officer in his slum. He then goes into hiding in a Rio favela. Neto dies in the hospital soon after.Seeking revenge, Matias, Nascimento and their fellow BOPE officers start making daily incursions into Baiano's slum to torture criminals into telling them of his whereabouts. One of them reveals that Edu told Baiano about Matias's meeting, which ultimately led to Neto's death. In a rage, Matias interrupts a peace walk, beats Edu up and insults Maria and the others, accusing them of being nothing but spoiled hypocritical drug users working for a dealer to provide for their work. Finally, the officers discover the exact location of Baiano and raid the slum. Baiano tries to escape, but as he runs across the rooftops, he is shot in the leg. Nascimento holds him at gunpoint, but Baiano pleads to the captain not to shoot him in the face, in order to perserve his face "for the wake". Nascimento then walks away, grabs a shotgun, hands it to Matias and tells him to shoot Baiano in the head, as a final test to ascertain Matias's worthiness as his true successor. Matias points the gun to the drug-lord's face, cocks the slide, and shows visible hesitation, but does not point the gun away. As the screen cuts to black a final gunshot goes off.
Output: Where is Baiano shot when he tries to escape running across the rooftops?