The USS Enterprise is sent to explore the "Class M" planet Nibiru. What started out as a mission to investigate and observe the inhabitants of the planet turns into a quest to save the planet from a volcano that could potentially wipe out the planet and all life that inhabits it. McCoy and Kirk are on a reconnaissance peace-keeping mission to the planet which is then jeopardized. They then have to high tail it to the Enterprise which is being harbored underwater. At the same time, Spock has been lowered via cable into the volcano to plant a "cold fusion" device that will halt the eruption. Due to the large amount of ash spewed into the air and the intense heat generated, Spock's cable snaps and he lands in the volcano, surrounded by lava. Sulu and Uhura have no choice but to fly their shuttle back to the Enterprise.
Once on board the Enterprise, Kirk wastes no time in trying to get Spock back on board. Spock is of course not interested in surviving the mission but more concerned in observing the prime directive of the Starfleet Academy - which is not to be seen nor heard among developing civilizations. Of course the opposite happens - Kirk and Uhura do everything they can to save Spock's life. Breaking prime directive, Kirk takes the Enterprise out of hiding and heads for the volcano where they beam Spock back on board. A relieved Uhura is fine that Spock is back safe and sound, but Spock is displeased that Kirk deliberately broke the rules rather than surviving.
Kirk tries to play off the fact that the burgeoning civilization saw the Enterprise as no big deal. What he doesn't know is that the new civilization has begun to worship the Enterprise and its crew. After being called back to Earth, Kirk is relieved of command, and Admiral Pike resumes command of the Enterprise. A very furious Admiral Pike grills Kirk for breaking the rules. During the meeting Spock reveals that while Kirk wrote a report in his Captain's log that broad brushed the truth, Spock was far more honest in his report. Kirk is demoted and he has to report back to Starfleet. While at a bar drowning his sorrows in alcohol, Kirk is confronted by Pike, who gives him a pep talk about how Kirk has to fight for what's important. Pike feels Kirk needs to learn a valuable lesson as a captain and tells Kirk he was the one who originally recruited Kirk, and Pike himself was recruited by Admiral Marcus.
Shortly afterward, Starfleet agent John Harrison, with the compliance of a Starfleet officer, bombs a Starfleet archive installation in London, having coerced a Starfleet officer into sneaking the bomb into the facility in exchange for healing his ailing daughter. An emergency meeting of high ranking officers is called at Starfleet headquarters, which Kirk attends as Pike's first officer. Moments after Kirk determines that Harrison seemingly bombed a non-vital Starfleet facility, the meeting falls under attack by by Harrison in a small Federation gunship. Kirk takes the gunship down, but Harrison escapes by transporting himself to an unidentified planet and Pike dies.
After Pike's funeral, Admiral Marcus authorizes Kirk to hunt down Harrison, who has fled to the Klingon homeworld of Qo'noS ("Kronos"). Since Qo'noS lies deep in Klingon territory and Starfleet is on the brink of war with the Klingon Empire, the Enterprise is supplied with 72 long-range prototype photon torpedoes, and is ordered to fire them all at Harrison's location once he is found. Admiral Marcus reinstates Kirk as captain of the Enterprise. Kirk accepts but only on the condition that he's allowed to reinstate Spock as his first officer. He then tells Kirk and Spock that London wasn't just a mere archive. It was a top secret branch of Starfleet that was designated "Section 31". Section 31's primary function was to study Klingon technology and to develop new capabilities that would defend Starfleet from the Klingons. The attack on Section 31 severely crippled Starfleet's abilities to defend itself. Admiral Marcus believes this was an act of war.
Kirk is renamed the Captain and has Spock reenlisted as his first officer. On the way to the Enterprise, Bones' medical testing annoys Kirk while he and Spock continue the fight they had previously about the Nibiru mission. Believing the new photon torpedoes could be dangerous to the ship, chief engineer Montgomery Scott refuses to take them aboard and tenders his resignation when ordered by Kirk to accept them. The Admiral's daughter, scientist Carol Marcus also joins the crew, under a false identity, and Pavel Chekov is promoted to Chief Engineer.
En route to the Klingon homeworld the Enterprise's warp core malfunctions, leaving the ship stranded in space a short distance from Qo'noS. With repairs underway, Kirk, Spock, and Uhura use a previously commandeered trader ship that they had confiscated and fly to Qo'noS. However, they are detected by Klingon patrol ships and are forced to land. Despite Uhura's attempts to negotiate, the Klingons prepare to kill the trio, when a mysterious figure attacks the Klingons. After wiping most of them out single-handedly, the attacker reveals himself to be John Harrison. He confronts the landing party, but surrenders after learning the precise number of torpedoes aimed at him. Kirk beats him severely for Pike's murder but Harrison seems to feel little pain or show any injury.
Back on the Enterprise, Harrison reveals his real identity: Khan, a genetically augmented superhuman who has been in cryo-sleep for 300 years after waging an unsuccessful war on Earth to eradicate all those inferior to himself and his superhuman comrades. He suggests Kirk should take a closer look at the 72 prototype torpedoes and gives him a set of spatial coordinates. Kirk orders McCoy to take apart one of the torpedoes, and contacts Scotty back on Earth to investigate the coordinates. The torpedoes are found to each contain a genetically-engineered human in cryo-sleep - the remaining members of Khan's crew from the Botany Bay. Khan explains that Admiral Marcus awakened Khan to force him to use his superior intellect and savagery to develop advanced weapons to start a war with the Klingons, keeping his crew as hostages. Kirk realizes that the Enterprise warp core has been sabotaged on Marcus' orders, making the covert operation to kill Khan a one-way ticket.
Kirk sends Carol Marcus and Dr. McCoy down to a remote planet to inspect one of the torpedoes. As the two investigate, Dr. McCoy finds out that there's something inside the torpedo: a cryo-frozen human - which is why Khan had an interest in the torpedoes in the first place -- inside them are 72 of his comrades from the past. Meanwhile, Kirk manages to regain contact with officer Montgomery Scott, who he tells was right all along about the torpedoes on the Enterprise - that who placed them on there was not to be trusted, and enlists Scott to find out the truth about who placed these weapons on the Enterprise.
At the same time Scott arrives at the coordinates which have been revealed by Khan; they are near Jupiter. Scotty discovers a secret Starfleet shipyard, which he infiltrates. Back on the Enterprise the defective warp core is brought back online, but Chekov discourages Kirk from using it yet. Shortly after, another ship arrives: an unregistered Federation battleship, the USS Vengeance - a massive vessel built strictly for combat which dwarfs the Enterprise. It is twice the size and designed to be operated by a minimal number of crewmembers, one if necessary. Admiral Marcus reveals himself as the commander of the vessel, demanding Kirk hand over Khan. Kirk refuses, and the Enterprise warps away to Earth, to return Khan to stand trial for his crimes.
Shortly after, the Enterprise is attacked in warp by the Vengeance, halting their escape near the Moon. Outgunned, the Enterprise is severely damaged. Ultimately Kirk agrees to hand over Khan and the 72 bodies in cryo-sleep in exchange for the lives of his crew. Marcus refuses and beams his daughter aboard the Vengeance to prevent her being used against him. As the Vengeance is about to destroy the Enterprise, it suffers a ship-wide power outage, caused by Scott who had boarded the ship earlier at the secret shipyard. As the Enterprise' weapons are too damaged to continue the fight, and knowing that Khan was the designer of Marcus' ship, Kirk allies himself with Khan and boards the enemy ship. They reunite with Scott and take the bridge. Meanwhile, Spock contacts Spock Prime to learn of Khan's history and how to defeat him. Khan betrays Kirk and takes control of the ship, injuring Carol Marcus and killing Admiral Marcus in the process. Khan negotiates with Spock for Kirk's life, and beams the 72 torpedoes aboard the Vengeance.
Khan beams Kirk and the rest of the boarding party back to the Enterprise in order to destroy it. Spock reveals that the torpedoes beamed to the Vengeance were armed, while the cryotubes still remain on the Enterprise. The torpedoes detonate, crippling the Vengeance and sending Khan into a furious rage, believing his crew have been killed. Both ships start descending towards the Earth's surface. The crew of the Enterprise manage to halt their ship's descent, as Kirk sacrifices his life to re-align the warp core, succumbing to radiation poisoning. Khan sets the final destination for the Vengeance: Starfleet headquarters in San Francisco. The enemy ship crashes into the city. Having survived the crash, Khan tries to escape in the chaos, but is pursued by an enraged Spock, whom had been with Kirk in his final moments. Meanwhile, Doctor Leonard McCoy discovers that Khan's blood may reanimate the dead Kirk. At the last possible moment, Uhura prevents Spock from killing Khan, and he is taken captive.
Kirk reacts positively to the treatment and is revived and put back on active duty. Khan is sealed into his cryotube and stored away with the rest of his crew. As the film ends, Kirk addresses a commemoration service one year later, the Enterprise is re-christened and departs for a 5-year mission of deep space exploration. The movie ends with Kirk reciting the Captain's oath and the Enterprise departing for its next mission.