Pepperland is a cheerful, music-loving paradise under the sea, protected by Sgt. Pepper's Lonely Hearts Club Band. The titular Yellow Submarine rests on an Aztec-like pyramid on a hill. At the edge of the land is a range of high blue mountains.
The land falls under a surprise attack from the music-hating Blue Meanies, who live in or beyond the blue mountains. The attack starts with magical projectiles fired from big artillery stationed in the blue mountains. The Blue Meanies seal the band inside a music-proof blue glass globe, they render the Pepperlanders immobile as statues by shooting arrows and dropping giant green apples upon them (a reference to the Apple Records music label), and drain the countryside of colour.
In the last minute before his capture, Pepperland's elderly Lord Mayor sends Old Fred, an aging sailor (whom the mayor calls "Young Fred"), to get help; he runs to the Yellow Submarine and takes off in it ("Yellow Submarine"). Old Fred travels to Liverpool ("Eleanor Rigby"), where he follows the depressed and aimless Ringo and persuades him to return to Pepperland with him. Ringo collects his "mates" John, George, and finally Paul in The Pier, a house-like building on the top of a hill. The five journey back to Pepperland in the yellow submarine. As they start learning to operate the submarine, they sing "All Together Now", after which they pass through several regions on their way to Pepperland:

Sea of Time â where time flows both forwards and backwards to the tune of "When I'm Sixty-Four". At one point, the submarine passes itself as it loops through time.
Sea of Science â where they sing "Only a Northern Song". Just before the song finishes, they pick up a monster.
Sea of Monsters â The monster is ejected into a sea inhabited by other weird monsters. Ringo presses the panic button on the submarine, ejecting him from the submarine and into the sea. He is seen riding one of the monsters, who tosses him around, and with the threat of Native American-like creatures, resulting in John pressing another button on the submarine, sending the US Cavalry to successfully defeat the Native Americans, rescuing Ringo. It is also where a monstrous "vacuum cleaner beast" sucks up all loose objects and people and then the entire landscape and finally itself, popping the submarine into a strange empty void.
Sea of Nothing â This blank region is where they meet Jeremy Hillary Boob Ph.D.("Phud"), a short pudgy creature with a painted clown face and cotton tail, but a highly studious and helpful ally to the Beatles, who sing "Nowhere Man" in reference to him. As they leave, Ringo feels sorry for the "Nowhere Man" and invites him to join them aboard the submarine.
Foothills of the Headlands â Thanks to Jeremy, this is where he and the Beatles are separated from the Submarine (and Old Fred) and where John sings "Lucy in the Sky with Diamonds". Pepper (foreshadowing that Pepperland is yet to come) causes the beings in the Headlands to sneeze, blowing the Beatles and Jeremy into the Sea of Holes.
Sea of Holes â Here, Jeremy is kidnapped by one of the Blue Meanies patrolling the outskirts of Pepperland. Ringo thoroughly investigates one of the endless number of holes and puts it into his pocket. While searching for Jeremy, Ringo jumps onto a green hole which turns the Sea of Holes into Sea of Green; from here, the group arrives in Pepperland, followed by Old Fred and the Submarine.
Reunited with Old Fred and the submarine, they look upon the landscape: a sorry sight. The beautiful flowers have become thorns, the once-happy landscape now a barren wasteland. Everyone is immobilised and made miserable by the evil Blue Meanies, only able to move when permitted (such as when the Meanies feel like bullying them). The Beatles, camouflaged as Pepperlandian cutouts, dress up as Sergeant Pepper's Lonely Hearts Club Band and steal some instruments (their own instruments were lost in the Sea of Monsters) from the warehouse where the Meanies impounded "all things that maketh music". The four are discovered at the last second (Ringo accidentally steps on a bagpipe) and a clown Meanie sounds the alarm, causing the Beatles to flee hastily from the Meanies' vicious multi-headed (and multi-bodied) dog. Once in the clear, after defeating some apple-bonkers, the four "rally the land to rebellion", singing "Sgt. Pepper's Lonely Hearts Club Band", eventually forcing the Blue Meanies to retreat. The Chief Blue Meanie retaliates, sending out his main enforcer, the Dreadful Flying Glove, but John easily defeats it by singing "All You Need is Love". Pepperland is restored to colour and its flowers re-bloom, as the residents, empowered by the Beatles' music, rise up and take up arms (flowers) against the Meanies, who are fleeing headlong back to the blue border mountains where they came from. The original Sgt. Pepper's Lonely Hearts Club Band are released (thanks to the hole carried in Ringo's pocket from the Sea of Holes) and Ringo rescues Jeremy. The Beatles then have a rematch with the four-headed Meanie dog, singing "Hey Bulldog", with the Beatles victorious once again (This scene was in the UK version). The Blue Meanies are forced to retreat, and the Chief Blue Meanie tries to save face by killing Jeremy, but Jeremy performs some "transformation magic" on him causing the Meanie to sadly concede defeat. John extends an offer of friendship, and the Chief Blue Meanie has a change of heart (partly due to the "transformation magic" performed by Jeremy) and accepts. An enormous party ensues, where everyone sings "It's All Too Much" with everyone living happily ever after.
At the end, we see the real Beatles in live-action, having returned home, playfully showing off their souvenirs: George has the submarine's motor, Paul has "a little 'LOVE'" and Ringo still has half a hole in his pocket (having supposedly given the other half to Jeremy, which Paul offers to fix "to keep his mind from wandering", a reference to "Fixing a Hole"). Looking through a telescope, John announces that "newer and bluer Meanies have been sighted within the vicinity of this theatre" and claims there is only one way to go out: "Singing!" The quartet obliges with a short reprise of "All Together Now", which ends with translations of the song's title in various languages appearing in sequence on the screen, which concludes with the words "Released through United Artists" on the bottom-right-hand-corner of the screen.
Who have a rematch with the four-headed Meanie dog?
The Beatles