Franklin Bean (Charlie Sheen) is shown in flashback with his father, a postal worker at his high school. His poor performance is attributed to a lack of discipline which a school officials assures the elder Bean can be fixed with a stint in the Army. Then, in present day, PFC Bean is attending his father's funeral before returning to his duty station in Germany. In his state of grief he gets drunk, punches an MP and breaks through a plate-glass window in a local bar. Bean's army lawyer secures a plea deal, struck by his attorney Captain Ramon Garcia (Abraham), in lieu of a court martial which involves him removing unauthorized tattoos from his hands (obtained during his drunken rampage), paying for a broken window and serving 90 days in the camp stockade. He is met at the gates by a decorated Korean War veteran Master Sergeant named Otis McKinney (Martin Sheen).
McKinney explains that the stockade is fairly small and, as a result, he is in complete charge of the compound while being supported by two guards; Corporals Harold Lamar and Gerald Gessner. Bean finds a sympathetic ear in stockade guard Corporal Lamar after learning he is just as afraid of McKinney and only "serving his own time." Gessner is a somewhat spineless lackey to McKinney whom he clearly admires and respects.
Bean is introduced to his fellow prisoners, all of them black and led by section leader Roosevelt Stokes (Fishburne). Stokes is serving an unspecified sentence for larceny and, despite his conviction, apparently retains his rank of Corporal. Bean resists McKinney by refusing to refer to him as sergeant and refusing most military customs and courtesies. The prisoner detail is regularly trucked to a nearby farm where they perform manual labor such as digging ditches and building fences. While there, Bean becomes obsessed with a nonfunctional and off-limits windmill. He requests permission to repair the windmill from MSgt McKinney through Corporal Lamar but his request is denied. Bean submits a written request to the commanding officer, secretly bypassing McKinney by passing his request through Lamar, who grants him permission to work on the windmill only during meal breaks.
Bean challenges fellow inmate Webb, a Harlem born boxer, to a pickup game of basketball after suffering a humiliating loss to him in a fist fight which was initiated after Bean accused Webb of stealing his gold zippo lighter. Bean agrees to pay Webb $10 if he loses and Webb agrees to help Bean with his windmill project if Bean wins. Bean wins the game and begins building trust and credibility among the other prisoners. Bean begins to connect with the others and learns of some of their crimes. He soon shares a bunk with Bryce (Mankuma), who was convicted of murder despite his pleas to the contrary. Bryce advises that he expects his appeal to fail and to eventually be shipped out of the stockade to be hanged. Lawrence (Toles-Bey), a fellow prisoner who harbors sympathetic views toward the Nation of Islam, reveals that he was convicted of rape and sentenced to seven years though he denies his crime. Among the prisoners is also the largely silent Harry "Sweetbread" Crane (Stewart) who is an inspiring vocalist who sings at church services and leads the prisoners' soulful marching cadence.
In the meantime, McKinney becomes increasingly irritated with Bean's refusal to submit to his authority. It is revealed that he is estranged from his son, whom he states is roughly Bean's age. When McKinney calls his presumably ex-wife on his birthday hoping to speak to his son he is told that his son is unavailable sending McKinney into a drunken bender in the enlisted club. In the middle of the night he tries to break into the prisoner compound to confront Bean while yelling challenges to him. The noise rouses both Lamar and Gessner. Lamar threatens to arrest McKinney and refuses to comply with his order to open the gates. Gessner, however, makes a move to comply but is stopped by Lamar. A fellow sergeant and friend of McKinney arrives on the scene and is warned by Lamar that he will arrest McKinney unless he takes him away immediately and gets him to bed. During a Sunday visit with a friend from his unit, Bean is informed that they are being sent to Vietnam and that he will likely join them there after he is released from the stockade.
McKinney decides to try a nicer tact with Bean and invites him to his office to talk through their differences while plying him with chocolates, which Bean refuses. Bean states that McKinney is a bully and he hates everything he stands for. McKinney dismisses him and is visibly angry. The next day, while Bean and Webb are nearly finished with the windmill repair, McKinney arrives on the scene with a written order from a Colonel in the Army Corps of Engineers to cease all work on the windmill and placing it off limits for all personnel. When McKinney isn't present Webb and Bean return to the windmill to activate it despite the loud protestations from Gessner.
In the middle of a rainy night McKinney arrives at the prisoner barracks in rain gear and a combat helmet while holding a rifle. He orders the prisoners into the yard and summons Gessner. He writes up all of the prisoners, and Gessner, for appearing in formation out of uniform as they are all still in their underwear. He orders the men into the back of a deuce-and-a-half and orders Gessner to drive them to the farm where they normally work. Upon arrival he dismisses Gessner and orders him back to his quarters. When Gessner questions the order, McKinney strikes him sending him face down into the mud. He departs and McKinney begins to march the prisoners in the deep mud quickly finding that he is unable to keep up with the younger men in the harsh conditions. He orders the prisoners into formation, throws the ammunition clip from his rifle behind him, and tells the men they should run to escape. He then draws his service pistol and begins firing toward the men while shouting incoherently. "Sweetbread" Crane begins wandering toward the windmill and climbing it. McKinney scrambles for his clip, murmuring "help me" as he tries to load his rifle. All the while the prisoners plead with Sweetbread to return and explain to McKinney that he has a tendency to wander off and isn't trying to escape. Sweetbread climbs down from the windmill and begins moving toward McKinney. Bean leaps toward him to try to protect him from McKinney's rifle fire but Sweetbread is struck in the head. Bean removes his shirt to try to stop the bleeding as the other prisoners subdue McKinney but the wound is fatal.
It is revealed that the remainder of Bean's sentence has been commuted by the commanding officer. McKinney is court-martialed for the shooting of Crane and is represented by Captain Garcia. Stokes testifies against McKinney and whispers to Bean, as he leaves the witness stand, that they have McKinney "on the gallows." Garcia elicits from Bean the testimony that McKinney said "help me" as he was loading his weapon. He argues that it couldn't possibly have been a muttering to himself as Bean would not have heard it from his distance and that this was actually a call for the prisoners to assist him with Crane. This, he argues, constitutes a "warning shot" and that the killing was lawful. McKinney is presumably cleared, though it is never explicitly stated. Garcia confronts Bean after the proceedings smiling as he tells Bean that he had no choice but to tell the truth otherwise he would have committed perjury. He then assures Bean that he knows how he feels. Bean replies "No sir, you don't" before saluting and attempting to visit the prisoners. Lamar informs him that they don't want to meet with him though he leaves gifts which Lamar promises to convey.
Bean visits McKinney, who despite his acquittal is committed to the base psychiatric unit. McKinney sits motionless in his room in a state of undress and refuses to speak to Bean. When Bean attempts to initiate conversation, McKinney slowly turns in his chair to face away from him.
As Bean prepares to leave camp to ship to Vietnam to join his unit, he makes peace with Gessner and receives best wishes from Lamar as they march the prisoners. Webb breaks ranks and tosses the stolen lighter to Bean advising him to stick close to the brothers in Vietnam and they'll keep him safe. The prisoners then call the chain gang cadence that Sweetbread used to call, turning to face Bean in an apparent reconciliation. Bean tearfully joins in the movements and cadence while observing the formation before saluting the men and departing for Vietnam.