On stardate 3134.0, the Starship Enterprise investigates temporal disturbances centered on a nearby planet. During the investigation, Sulu is caught in a console explosion and suffers a heart flutter. Doctor McCoy is summoned to his aid and decides on a cordrazine shot to awaken him. Moments later, McCoy accidentally injects himself with an overdose of serum causing him to become violently paranoid. Delusional, McCoy flees from the bridge and beams down to the planet.
Captain Kirk forms a landing party made up of two security guards, himself, Spock, Scotty, and Uhura. Once on the planet, Spock finds that the source of the time distortions is an ancient ring of a glowing, stone-like material. The ring speaks and identifies itself as the "Guardian of Forever", explaining that it is a doorway to any time and place — with periods of history displayed in the opening. The team soon locates McCoy, however he runs away and leaps through the portal before anyone can stop him. Suddenly, everything seems to shift and the landing party loses contact with the Enterprise. The Guardian informs the landing party that history has just been altered and as a result, the Enterprise has disappeared.
Kirk believes that McCoy somehow altered the past, erasing the history that they knew. Kirk asks the Guardian to loop the history images again and he and Spock get ready to jump through to a time just before McCoy entered so that they can correct what McCoy has changed. Kirk and Spock leap through at the correct moment and materialize in New York City, back on Earth during the 1930s Great Depression era. Their uniforms and Spock's ears shock a passerby, so Kirk steals some clothes he spots hanging on a fire escape and the two hide in the basement of a nearby building. There they meet a woman named Edith Keeler (played by Joan Collins), who identifies herself as a social worker of the 21st Street Mission. They apologize for trespassing and offer to work for her. Their kindness wins her over and she allows them to stay. In the meantime, Spock begins to construct a processor interface and uses it to find out what part of history McCoy has altered.
Kirk soon begins to fall in love with Edith. He finds her a remarkable visionary with a positive outlook about what the future holds for mankind. McCoy materializes at this point, and stumbles into the 21st Street Mission, before an encounter with a homeless man. Edith sees him in line and rushes to his aid. McCoy still looks very ill and Edith takes him to lie down.
Spock finally finishes the interface and he and Kirk analyze the data. The information it reveals is shocking as they discover Edith ought to have died soon in a traffic accident, but McCoy's actions have prevented that fate. If she had survived, she would have formed a popular pacifist movement at the outset of World War II and met with Franklin D. Roosevelt. This meeting would delay the entry of the United States into the war and allow Nazi Germany time to develop a nuclear bomb and conquer the world. Kirk is appalled by the fact that if she doesn't die as she is supposed to, history will be altered forever. Meanwhile, Edith nurses McCoy, who tells her who he is and where he is from. Edith does not believe his fantastic-sounding story, but tells him that he would fit in nicely with her new eccentric boyfriend who will later be taking her to a movie starring Clark Gable, an actor with whom McCoy is not familiar.
Later, as Kirk and Edith start to walk toward the movie house, she mentions off-handedly that her new friend McCoy didn't know who Clark Gable is. Kirk however, is excited to learn that McCoy is alive and well and emphatically tells Edith to "Stay right here," while he dashes across the street to notify Spock. As he reaches Spock, McCoy exits the mission right in front of them. The three comrades enjoy an enthusiastic reunion while Edith watches them, intrigued, from the street corner. She slowly crosses the street to join them, but is oblivious to a fast-moving truck that is approaching her.
Kirk takes a step in her direction instinctively and freezes when Spock says, "No, Jim!" McCoy then sees Edith's danger and turns to move past Kirk into the street. Kirk holds McCoy back, the truck hits Edith and she is killed. The shocked McCoy says to Kirk "I could have saved her...do you know what you just did?" Kirk pushes him away, speechless, and Spock says quietly, "He knows, Doctor. He knows." With Edith's death, history reverts to its original timeline and Kirk, Spock and McCoy return to the Guardian's planet. The rest of the landing party still waits and Scotty indicates that the three had only been gone for a few moments. The Guardian says, "Time has resumed its shape. All is as it was before." and adds, "Many such journeys are possible. Let me be your gateway." Uhura indicates the Enterprise is ready to beam them back up and Kirk responds numbly "Let's get the hell out of here."
This episode was remastered in 2006 and aired October 7, 2006 as part of the 40th anniversary remastering of the Original Series. It was preceded a week earlier by "The Naked Time" and followed a week later by "I, Mudd". Aside from remastered video and audio, and the all-CGI animation of the USS Enterprise that is standard among the revisions, specific changes to this episode also include:
The script was commissioned in early 1966 from Harlan Ellison. Justman and Solow's book Inside Star Trek recalls that the script was delivered late.
The production staff considered Ellison's script excellent (Bob Justman wrote a memo saying, "This is the best and most beautifully written screenplay we have gotten to date ... If you tell this to Harlan, I'll kill you", though director Joseph Pevney said, "Harlan had no sense of theatre...in the original script's dramatic moments, it missed badly), but they had several concerns. As originally written, the episode would have been too long for a one hour show, too expensive to stage, with too many speaking parts and elaborate special effects. Also, several plot elements—such as a member of the crew dealing drugs and Kirk preparing to sacrifice his crew to be with Edith—led the producers to feel that the teleplay was simply "not Star Trek." Ellison did a number of rewrites himself, delivering his Second Revised Final Draft in December 1966. The story was still considered too expensive to shoot as written and was instead rewritten internally, variously by Steven W. Carabatsos, Gene L. Coon, D. C. Fontana and Gene Roddenberry himself. Ellison was unhappy with the rewrites and considered disowning the script by putting his "Cordwainer Bird" pseudonym on it.
Part of the reason for this controversy was a subtle but important change in Edith Keeler's character. In the original script, she was a social worker with a vague hippie philosophical bent, while in the final version, she was changed into an all-out war protester. The version that was aired carried the implication that anti-war movements were harmful to the future of humanity. This was particularly aimed at the anti-Vietnam movement that was gaining momentum at the time. When producer Robert Justman was asked if the episode was intended, "to have the contemporaneous anti-Vietnam-war movement as a subtext," he replied, "Of course we did. This new thematic element criticizing the anti-war movement ran counter to Ellison's strongly held anti-war views, established in many of his writings.
According to Ellison, Roddenberry would later repeatedly claim that Ellison's original script had Scotty dealing drugs, but Scotty does not even appear in that script. Ellison set out his side of the story in a 1995 book containing two drafts of his story outline, his first draft teleplay and the teaser and first act of his second revised draft (the latter dated December 1966).
The episode finally started shooting on February 3, 1967, and finished on February 14, 1967. It took seven and a half days to film, more than was typical for an episode, and according to Inside Star Trek came in at $250,000, compared to the weekly average of around $185,000.
The ancient ruins were allegedly the result of someone misreading Harlan Ellison's description in the script of the city as "covered with runes."
In addition to Ellison's 1996 book the original script was published in 1976 in "Six Science Fiction Plays", edited by Roger Elwood (ISBN: 0671487663).
The filmed version of "The City on the Edge of Forever" is considered the best episode of the original series by many critics such as Entertainment Weekly. TV Guide ranked it #68 in their 100 Most Memorable Moments in TV History feature in its July 1, 1995 edition, and also featured it in another issue on the 100 greatest TV episodes of all time. It is one of the most widely acclaimed episodes of the original series of Star Trek. It was awarded the 1968 Hugo Award for Best Dramatic Presentation at that year's World Science Fiction Convention. It would be twenty-five years before another television program would receive that honor; the next recipient being the Star Trek: The Next Generation episode "The Inner Light".
Harlan Ellison's original version won a Writers Guild of America Award for best dramatic hour-long script. Gene Coon said at the time, "If Harlan wins, I'm going to die", and that, "There are two scripts up tonight for the Writers' Guild Award, and I wrote them both. Gene Roddenberry noted that, "...many people would get prizes if they wrote scripts that budgeted out to three times the show's cost". In the documentary To Boldly Go... included in the Season 1 DVD set, Nimoy characterizes the episode as a high watermark in the series, calling it "good tragedy."
In the original script, Lieutenant Richard Beckwith, a drug dealer selling the illegal "Jewels of Sound," kills Lieutenant LeBeque after he threatens to expose Beckwith's activities. After escaping to the planet's surface, with Captain Kirk, Mr. Spock, Yeoman Rand and six Security guards close on his heels, he enters a Time Vortex, watched over by the Guardians of Forever, to escape. The time changes he effects cause the Enterprise to become a pirate vessel.
The rest of the show is roughly the same (with Keeler being the focus of the time travel, Kirk's growing love for her), but with more emphasis on Kirk and Spock spying on Keeler, waiting for Beckwith to find her. The script also includes an additional character in the person of a legless World War I veteran known as Trooper. Beckwith murders Trooper with a shot from a phaser, but his death, unlike Edith Keeler's survival, does not alter the continuity of time; Kirk and Spock rationalize that Trooper's life was unimportant, to Kirk's great distress.
The ending has Beckwith being captured, and Edith Keeler being hit by a truck in a fatal vehicle accident. But in this version, Beckwith attempts to save Edith, and Spock must tackle and stop him. Captain Kirk, knowing Edith must die, but wanting her to live, as he has fallen completely in love with her, is frozen in indecision and does nothing.
With the timeline set right, Beckwith attempts to escape again, but the Guardians of Forever have set a trap for him—he finds himself in an exploding supernova, and just before he dies a fiery death, is pulled backwards in time and forced to relive his agonizing death again and again for all eternity.
The very last scene was a quiet one between Kirk and Spock, where Spock treats his captain compassionately, telling him that "no other woman was ever offered the universe for love." In his adaptation of the story in Star Trek 2, James Blish explained to readers that he tried to preserve the best elements of both Ellison's original script and the final rewrite. In Blish's version, Kirk allows Edith to die, with the result that Spock tells him, "No other woman was ever almost offered the universe for love."
The Second Revised Final Draft had McCoy bitten by a toxic animal, which caused him to go insane and beam down to the Guardian's planet.
Ellison's original story outline had the action set in Chicago instead of New York, and the Slum Angel's name was Sister Edith Koestler, not Keeler. This confusion seemed to carry over into the final storyline, where in the closing credits of the episode that ultimately aired, the character is erroneously identified as "Sister Edith Keeler."
The events of City on the Edge of Forever are revisited in the Crucible trilogy, released for Star Trek's 40th anniversary. Ellison threatened to launch legal action against Pocket Books over this series, claiming his original scriptwriting contract gave him rights to elements of that episode. He demanded a "trailer-truck full of cash", threatening to sue and prevent publication of the series if not paid. Peter David's Imzadi was immune from such proceedings due to the author's close relationship with Ellison and the fact that he requested permission to use elements of the episode.