"In the Penal Colony" presents a graphic depiction of human cruelty and conceptions of justice through Judeo-Christian references. The short story tells of an explorer who arrives at a penal colony to observe a punishment machine. An officer proudly explains how the machine uses sharp needles to slowly inscribe relevant commandments on the prisoners' bodies. The explorer says he finds the machine morally repugnant and the officer climbs into the machine himself. The words "Be Just" are inscribed on the officer's body and he is killed.
The story focuses on the Explorer, who is encountering the brutal machine for the first time. Everything about the machine and its purpose is told to him by the Officer. The Soldier and the Condemned (who is unaware that he has been sentenced to die) placidly watch from nearby. The Officer tells of the religious epiphany the executed experience in their last six hours in the machine.
Eventually, it becomes clear that the use of the machine and its associated process of justice– the accused is always instantly found guilty, and the law he has broken is inscribed on his body as he slowly dies over a period of 12 hours – has fallen out of favor with the current Commandant. The Officer is nostalgic regarding the torture machine and the values that were initially associated with it. As the last proponent of the machine, he strongly believes in its form of justice and the infallibility of the previous Commandant, who designed and built the device. In fact, the Officer carries its blueprints with him and is the only person who can properly decipher them; no one elseis allowed to handle these documents.
The Officer begs the Explorer to speak to the current Commandant on behalf of the machine's continued use. The Explorer refuses to do so, and says that he will not speak against it publicly, but will instead give his opinion to the Commandant privately and then leave before he can be called to give an official account. With this, the Officer frees the Condemned and sets up the machine for himself, with the words "Be Just" to be written on him. However, the machine malfunctions due to its advanced state of disrepair; instead of its usual elegant operation, it quickly stabs the Officer to death, denying him the mystical experience of the prisoners he had executed.
Accompanied by the Soldier and the Condemned, the Explorer makes his way to a tea house in which he is shown the grave of the old Commandant. Its stone is set so low that a table can easily be placed over it; the inscription states his followers' belief that he will rise from the dead someday and take control of the colony once more. As the Explorer prepares to leave by boat, the Soldier and the Condemned try to board but are repelled by the Explorer himself.