M-5 was installed onboard the USS Enterprise in 2268 as a test of its capabilities. It was due to command and control the ship during several battle simulations, where up to four other starships would attack the Enterprise. Manned with only a skeleton crew, the ship was completely run by the computer.
The unit was located in main engineering, and tapped directly into the ship's main power grid. When requiring more power, it would shut down unnecessary systems, including life support on decks without crewmembers.
During battle drills, the computer's self-preservation instinct became dominant, resulting in the destruction of the robot ship Woden and the deaths of several hundred Starfleet officers when it destroyed the USS Excalibur.
The senior crew attempted to cut off the computer from the ship's controls, but M-5 rerouted command functions through new data lines, and kept sending false signals through the original ones. The computer could also generate a force field around itself, effectively preventing anyone from coming near it.
Captain James T. Kirk made the computer self-destruct by asking it if it was right to kill another being. M-5 said that it was a crime against the laws of God, and deactivated itself. (TOS: "The Ultimate Computer")