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. 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 is also interested 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. To break the 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 more interested 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 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. This gets Kirk 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. An emergency meeting of high ranking officers is called at Starfleet headquarters, which Kirk attends as Pike's first officer.
The meeting is attacked by Harrison in a small Federation gunship. Kirk takes the gunship down, but Harrison escapes 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 prime 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. On board the Enterprise, Kirk is renamed the Captain and has Spock reenlisted as his first officer.