The best Star Trek episodes combine incomprehensibly powerful alien technology, mental instability, literary allusions, a cliffhanger resolved by highly unorthodox tactics, a ponderous rumination on man's inhumanity to man, and, of course, a some huge explosions.
Aired during Star Trek's second season, "The Doomsday Machine" has all the ingredients. It begins, as many episodes do, with a faint distress signal. After tracking down the signal through a few destroyed solar systems, the Enterprise comes upon the wreckage of her sister ship, the USS Constellation.
Kirk, McCoy, Scotty, and a few expendables beam aboard the Constellation, leaving Spock in charge of the Enterprise. They arrive to find that only one crew member, Commodore Matt Decker, remains, and by his wild eyes and unkempt appearance, it's immediately clear that he's been through something that left him a few dilithium crystals short of a warp core.
It turns out that the Constellation was attacked by a monstrous "planet killer." In an attempt to save his crew, he teleported them to a nearby planet, which the planet killer, true to its name, destroyed, leaving Decker alone on his ship.
Kirk and McCoy conclude that the planet killer was a doomsday weapon, a deterrent created by a presumably long-dead alien civilization from outside the galaxy. Never intended to be used, it somehow activated and is now running amok, and is headed for a densely populated region.
The doomsday weapon – which looks like a giant corn dog wrapped in aluminum foil – returns. Decker and McCoy beam aboard the Enterprise. Decker, the now highest ranking officer aboard, takes command and gets all Captain Ahab-ey, attempting to attack the planet killer at close range.
Thanks to a daring plan by Kirk and some "inverse phasing" on the Enterprise's transporter by Scotty, it all works out in the end (except for poor Decker, who flies a shuttlecraft into the maw of the doomsday machine at the end of the second act).
According to the encyclopedic Trek site Memory Alpha, James Doohan, who portrayed Scotty, once remarked that this was his favorite Star Trek episode.