The film covers the court-martial of two U.S. Marines, Lance Corporal Dawson and Private Downey, who killed a fellow Marine, Private Santiago, at the Guantanamo Bay Naval Base in Cuba. Santiago compared unfavorably to his fellow Marines, had poor relations with them, and failed to respect the chain of command in attempts of being transferred to another base. An argument evolves between base commander Colonel Jessup and his officers: while Jessup’s executive officer, Lieutenant Colonel Markinson advocates that Santiago be transferred immediately, Jessup regards this as akin to surrender and orders Santiago’s commanding officer, Lieutenant Kendrick, to train Santiago into a better Marine.

When Dawson and Downey are later arrested for Santiago’s murder, naval investigator and lawyer Lieutenant Commander JoAnne Galloway suspects that they carried out a “code red” order, a violent extrajudicial punishment. Galloway requests to defend them, but instead the case is given to Lieutenant Daniel Kaffee, an inexperienced and unenthusiastic U.S. Navy lawyer. There is initial friction between Galloway, who resents his tendencies to plea bargains, and Kaffee, who resents her interference. Kaffee and his friend, Captain Jack Ross, who represents the prosecution, negotiate a bargain but Dawson and Downey refuse to go along. They insist that they were ordered by Lieutenant Kendrick to shave Santiago’s head, minutes after Kendrick publicly ordered the platoon not to touch the would-be victim, and did not intend their victim to die. Kaffee is finally won over by Galloway and takes the case to court.

In the course of the trial, the defense manages to establish the existence of “code red” orders at Guantanamo and that Dawson specifically had learned not to disobey any order, having been denied a promotion after helping out a fellow Marine who was under what could be seen as a “code red”. However, the defense also suffers setbacks when a cross-examination reveals that Private Downey wasn’t actually present when he and Dawson supposedly received the “code red” order. Lieutenant Colonel Markinson reveals to Kaffee that Jessup never intended to transfer Santiago off the base but commits suicide rather than testify in court.

Without Markinson’s testimony, Kaffee believes the case lost and returns home in a drunken stupor, having come to regret that he fought the case instead of arranging a plea bargain. Galloway, however, convinces Kaffee to call Colonel Jessup as a witness despite the risk of being court-martialled for smearing a high-ranking officer. Jessup initially outsmarts Kaffee’s questioning but is unnerved when the lawyer points out a contradiction in his testimony; Jessup had stated that he wanted to transfer Santiago off the base for his own safety but if he ordered his men to leave Santiago alone and if Marines always obey orders, Santiago would have been in no danger. Under heavy pressure from Kaffee and unnerved by being caught in one of his own lies, Jessup finally snaps, extols his own importance to national security and ultimately confesses to ordering the “code red”. As he angrily justifies his actions, Jessup is arrested.

Soon afterwards, Dawson and Downey are cleared of the murder charge but found guilty of “conduct unbecoming a United States Marine” and dishonorably discharged. Dawson accepts the verdict but Downey does not understand what they had done wrong. Dawson explains that they had failed to stand up for those too weak to fight for themselves, like Santiago. As the two prepare to leave, Kaffee tells Dawson he does not need a patch on his arm to have honor. Dawson, who had previously been reluctant to respect Kaffee as an officer, barks, “Ten hut! There’s an officer on deck!” and salutes Kaffee.