They travelled back to where 23rd century man had never gone before. To a mad, crazy, outrageous time. 1986.
The fourth episode in the Star Trek films. As part of the deal with reincarnating Spock, Leonard Nimoy got to direct this film. He also helped write it along with Gene Rodenberry and friends. Most people I know consider it to be the funniest of the Star Trek episodes (excluding the recent ones involving Data getting emotional).
This movie takes place almost immediately after Star Trek III: The Search for Spock leaves off. Spock is brought back to life from being dead (although he's a bit out of touch with reality), and the crew is flying back to Earth. However, before they can get there, a big alien probe parks itself in earth's orbit and begins broadcasting some Alien signal that disables all the starships and systems on earth, and creates massive havoc with Earth's climate.
Spock analyzes the signal and determines it to be the sound of humpback whales. The probe is trying to contact whales, but they went extinct in the late 20th century. Kirk decides to travel back in time to catch some whales and bring them back... to the future. Using the Klingon bird of prey, they slingshot around the Sun at Warp 9.9, which somehow shoots them into the past, to the year 1986. (The same method was used in the episode "Tomorrow Is Yesterday.")
They cloak the ship and decide that the best place to look would be...San Francisco. Once they get there, they discover that the time travel fractured their dilithium crystals, so they will need some radioactive source to fix them or power the ship. Not only that, but the ship can't hold whales, they're going to have to build something to store them.
The crew lands the ship in Golden Gate Park. Kirk reminds everyone "Everybody remember where we parked," as if the crushed garbage cans and grass outline underneath an invisible ship aren't a giveaway. The crew splits up to get their mission accomplished faster. Kirk and Spock go and look for whales, McCoy and Scotty go and look for materials to contain the whales in the ship (like aquarium glass), and Chekov and Uhura go look for a "nuclear wessel" as Chekov says in his Russian accent. Sulu, um, parties or something while everyone else goes off on earth to save the earth later.
What makes this movie funny is that the entire Star Trek cast is forced to deal with ordinary Earth from the 1980's. Spock avoids everyone staring at his pointy ears by giving himself a karate headband. Kirk isn't sure how to reply to insults, and Spock is just bewildered by the "colorful metaphors" that people say to him in "primitive" earth society. He eventually gives the Vulcan nerve pinch to a punk who gives him the finger and bothers him with a boombox. They finally find two Humpback whales in an aquarium, whereupon Spock dives in and mind-melds with one. Kirk is stuck trying to explain Spock's bizarre behavior to the staff "Oh, him? He's harmless. Part of the free speech movement at Berkeley in the sixties. I think he did a little too much LDS." Kirk meets this beautiful doctor who is planning on setting the whales free into the ocean, so he begins to cozy up to her.
Every character is stuck trying to make sense of the "primitive" 20th century. Scotty tries using voice commands on a Macintosh "Computer? Hello Computer," and tries to talk into the mouse before someone points out the "quaint" keyboard. McCoy is disgusted by the ancient medical technology he sees, calling it "the Dark Ages" when he learns about dialysis. Sulu learns to use something called the Yellow Pages. Spock tries to learn how to curse. Chekov gets arrested for sneaking on a nuclear aircraft carrier also known as "USS Enterprise" and accused of being a Russian Communist spy with a ray gun. Hijinks ensue.
Kirk gets close to the scientist who is in charge of the whales. Scotty gives the secret of Transparent Aluminum to an engineer in exchange for aquarium glass. Kirk and McCoy break Chekov out of a hospital. Sulu gets ahold of a helicopter. Long story short, they save the whales from a whaling ship, take the lovely female scientist with them to the future (as per her request) and slingshot back to the future.
When they get there, the probe disbles their ship too as they get close, and they crash into the San Francisco bay. Kirk swims underwater and releases the whales, who speak in whale-speak to the probe, which shuts off and goes away.
Kirk and his crew saved the Earth once again, but are brought to trial for the events of Star Trek Part III. (Harry Mudd was going to be a character witness, but that was dropped from the script) In the end, most of the charges are dropped, and Kirk gets reduced in rank to "Captain" from his earlier rank of Admiral.
Interesting facts (courtesy IMDb):
This was the only Star Trek film where nobody is killed. Weapons were fired, but not at anybody except whales.
The success of this film led to offers by several US TV networks to produce a new Trek TV series. Instead, Paramount gave the green light to produce the syndicated "Star Trek the Next Generation" (1987).
According to actor George Takei, when McCoy, Scotty and Sulu are standing in front of the building with Yellow Pages ad, a door opens and an asian woman appears. The scene in the movie ends at this point but originally this woman was to begin shouting for a young boy named Hikaru, who would run into Sulu. Sulu would realize that this boy was his great-great-(etc.) grandfather. The young boy hired for this scene began to cry on the set before the shot and they were unable to get him to do the scene. With no one to replace him, the scene was never shot.