The player takes the role of an unnamed space marine ("Doomguy") who has been punitively posted to Mars after assaulting his commanding officer, who ordered his unit to fire on civilians. The Martian space marine base acts as security for the Union Aerospace Corporation, a multi-planetary conglomerate, which is performing secret experiments withteleportation by creating gateways between the two moons of Mars, Phobos and Deimos. Mars is considered by space marines to be the dullest assignment imaginable. This all changes when the UAC experiments go horribly wrong. Computer systems on Phobos malfunction, Deimos disappears entirely, and "something fragging evil" starts pouring out of the gateway, killing or possessing all UAC personnel.
Responding to a frantic distress call from the overrun scientists, the Martian marine unit is quickly sent by ship from Mars to Phobos to investigate, where the player character is left to guard the perimeter with only a pistol while the rest of the group proceeds inside. The marine hears assorted radio messages, gunfire, and screams, followed by silence: "Seems your buddies are dead." The player cannot navigate the ship off of Phobos alone and sees that the only way out is to fight through the Phobos complex.
As the last man standing, the player character's mission is to fight through the entire onslaught of demonic enemies by himself in order to keep them from attacking Earth. Knee-Deep in the Dead, the first episode and the only one in theshareware version, is set in the high-tech military bases, power plants, computer centers and geological anomalies on Phobos. It ends with the player character entering the teleporter leading to Deimos, only to be overwhelmed by monsters.
In the second episode, The Shores of Hell, the marine has successfully teleported to Deimos. He fights his way through installations on Deimos, similar to those on Phobos, but warped and distorted from the demon invasion and interwoven with beastly architecture. After defeating the titanic Cyberdemon, the marine discovers the truth about the vanished moon: it is floating above Hell.
The third episode, called Inferno, begins after the marine climbs off Deimos to the surface. The marine fights his way through Hell and defeats the Spider Mastermind that planned the invasion. Then the marine finds a hidden doorway back to Earth opens for the hero, who has "proven too tough for Hell to contain". However, a burning city and a rabbit's head impaled on a stake (named in The Ultimate Doom as the marine's pet rabbit, Daisy) show that the demons have invaded Earth, setting the stage for Hell on Earth. The sequel retcons the events of Doom as an alien invasion of the Mars moon bases.
In The Ultimate Doom expansion, in the fourth episode Thy Flesh Consumed, it tells that the marine fought valiantly against the hordes of demons that the Spider Mastermind sent through that hidden doorway but ultimately the forces of Hell prevailed in the invasion of Earth. The locales of Thy Flesh Consumed are varied, including a mix of high-tech bases and demonic temples, though the atmosphere appears to be Earth.