In New York City, four men armed with submachine guns and using code names (Mr. Blue, Mr. Green, Mr. Grey, and Mr. Brown), wearing similar trenchcoat, glasses and mustache disguises, board the Downtown-bound 6 subway train at different station stops (Green at 59th Street, Grey at 51st Street, Brown at Grand Central, and Blue at 28th Street). The men take seventeen passengers and the conductor hostage, isolate them in the train's first car and then separate the car from the rest of the train.
Meanwhile, Zachary Garber (Walter Matthau), a cynical and curmudgeonly yet light-hearted New York City Transit Authority police lieutenant, is leading a tour of New York's subway command center when it is interrupted by Blue's radio announcement that "your train has been taken". Blue (Robert Shaw), the leader of the hijackers, reveals their demands: a ransom of $1 million, to be delivered within one hour, or else they'll kill one passenger per minute after that.
Garber, the sarcastic lieutenant Rico Patrone (Jerry Stiller), and other transit workers cooperate while trying to guess how the criminals intend to get away. The supervisor at Grand Central decides to confront the hijackers himself. As he approaches the train, Grey (Hector Elizondo) shoots him dead. Various clues surface for Garber: Blue has an English accent, while Green (Martin Balsam) has a cold and periodically sneezes over the radio, to which Garber says "Gesundheit." Garber surmises that as the hijackers are able to operate the train, one is probably a disgruntled transit worker. He also learns that one of the hostages is an undercover police officer.
The mayor finally agrees to pay the ransom. Conversations between the hijackers reveal that Blue was a mercenary in Africa and Green was a motorman caught in a drugs bust. There is also an undercurrent of tension between Blue and Grey; Blue confides to Green that he believes Grey is "mad" and potentially trouble. Garber requests additional time from Blue, believing that the process of gathering the money and transporting it to the train within the hour is practically impossible. Blue refuses to grant any extra time but eventually agrees to a slight change of the conditions of the deadline; the money must now at least reach the 28th Street station nearest the train by the 3:13pm deadline rather than the train itself. During the tense wait for the money, a police officer exchanges gunfire with the hijackers. In retaliation, Blue kills the conductor. The police dispatch a squad car with the ransom money, but it crashes. Garber daringly bluffs to buy time, telling the hijackers that the money has been delivered, delayed only by the walk down the tunnel. A reluctant Blue agrees to wait.
A police motorcycle delivers the ransom and then it is delivered on foot. With the money finally in hand, Blue gives Garber their next demands: that electric power be restored to the subway line, that all signals in the path of the train be set to green, and all police officers be cleared from the tunnel. Having overridden the train's dead-man's switch, a safety device requiring a motorman to continually press down on the throttle or else the train will stop, the hijackers get off the train and set it in motion. As the train starts to move, the undercover officer jumps off and hides. The car begins to travel faster and faster, as no one is controlling its speed.
While following the runaway train above ground, Garber becomes convinced that it is a diversion and that the hijackers must have left it. In the tunnel, the hijackers begin their escape into the emergency exit; however, Grey refuses to leave his gun behind, resulting in a stand-off with Blue, who shoots him dead. The undercover officer manages to kill Brown (Earl Hindman) with one shot. Green escapes onto the street, while Blue shoots at the officer until he wounds him. Garber arrives and, drawing on Blue, orders him to surrender. Told that New York no longer has the death penalty, Blue electrocutes himself by stepping onto the third rail. Meanwhile, the runaway car finally encounters a red signal upon the approach to the South Ferry loop and grinds to a halt; the remaining hostages are safe.
The three dead hijackers are identified, and it is clear that none had piloted trains, so Garber concludes that the remaining hijacker must be the former transit employee. Working their way through a list of former motormen "discharged for cause", Garber and Patrone pay a visit to Harold Longman (Green), who bluffs his way through the officers' questioning. The officers find Longman's alibi weak, but start out the door, until Longman sneezes and Garber says "Gesundheit." Garber re-opens the door, and his expression indicates that he has found the final hijacker.

Question: What type of code names do the four armed men use?
Answer: They use colors as code names.
Alternative answer: green, grey, brown, blue