As the Enterprise passes through a region filled with temporal anomalies, McCoy accidentally injects himself with a serum that drives him temporarily insane. He beams himself down to a nearby planet. Kirk, Spock, Scotty, Uhura, and two redshirts follow him to the planet, just in time to watch him leap through a stone portal and disappear.
The landing party is then informed by a godlike entity that history has been altered and that the Enterprise no longer exists.
It turns out that McCoy had gone back to 1930s New York, where he saved the life of social worker Edith Keeler, played by Joan Collins. But then we learn that Keeler will go on to form a pacifist movement that delays the entry of the United States into World War II, allowing the Nazis to take over the world. The crew realizes that Keeler, whom Kirk finds himself falling in love with, must die in order to set history right.
The episode, which won a Hugo, was written by sci-fi great Harlan Ellison.