The film follows the plot of the TV series SpongeBob SquarePants, focusing on the anthropomorphic sea sponge of the same name (Tom Kenny). SpongeBob dreams about managing the Krusty Krab restaurant, which is in trouble because a customer has no cheese on his Krabby Patty, but SpongeBob saves the day. He wakes up and cheerfully prepares for the opening ceremony for the Krusty Krab 2, hoping that his boss Mr. Krabs (Clancy Brown) will promote him to manager of the new restaurant built next door to the original Krusty Krab. At the ceremony, SpongeBob is passed over; his co-worker, Squidward Tentacles (Rodger Bumpass), has been given the promotion because Mr. Krabs thinks he is “more mature” than SpongeBob.
Meanwhile, Plankton (Mr. Lawrence), Mr. Krabs’ business rival, devises a plot to steal the Krabby Patty secret formula and frame Mr. Krabs. He steals King Neptune’s (Jeffrey Tambor) crown that night, leaving evidence that pins the crime on Mr. Krabs, and sends the crown to Shell City, a distant, mysterious land from which no fish has returned. That night, SpongeBob goes to his favorite restaurant, Goofy Goober’s; he drowns his sorrows in ice cream with his best friend, Patrick Star (Bill Fagerbakke), waking up the next morning with a headache. King Neptune barges into the Krusty Krab 2 the same morning and threatens to slay Mr. Krabs. Although SpongeBob criticizes Mr. Krabs shortly after he arrives, he promises Neptune that he will retrieve the crown from Shell City. Neptune freezes Mr. Krabs, still certain that he is the culprit, and tells SpongeBob to return with the crown in six days for him to spare Mr. Krabs. SpongeBob and Patrick leave for Shell City in the Patty Wagon, a car shaped like a Krabby Patty.
In Bikini Bottom, Plankton steals the Krabby Patty formula and uses it to produce and sell Krabby Patties at his restaurant, the Chum Bucket, with the claim that Krabs bequeathed him the recipe. He sends a hitman named Dennis (Alec Baldwin) to pursue SpongeBob and Patrick. Squidward discovers the truth about Plankton stealing Neptune’s crown and tries to alert Neptune. However, Plankton uses mind-controlling bucket helmets disguised as souvenirs to control Bikini Bottom’s residents, including Squidward, and renames the city Planktopolis.
Meanwhile, SpongeBob and Patrick encounter a dangerous trench, but Neptune’s daughter Mindy (Scarlett Johansson) helps them past it by making them think she can transform them into men. They are stopped by Dennis, who tries to crush them with his spiked boots, but he is in turn stepped on by a massive “cyclops” (a diver) (Neil Ross). The “cyclops” grabs SpongeBob and Patrick, and goes to his beachside store, revealed to be Shell City. At the store, SpongeBob and Patrick find the crown, but are nearly killed in a lethal drying-out process with the heat lamp turned on. Their tears short-circuit the heat lamp; its smoke activates the sprinkler system, reviving their bodies and the other dried sea creatures to be sold as souvenirs. As the sea creatures attack the diver, SpongeBob and Patrick take the crown and head for the beach. When they lose their way home, David Hasselhoff offers them a ride; Dennis catches up to them but is knocked by a catamaran back into the sea.
Back at the Krusty Krab 2, Neptune arrives to execute Mr. Krabs. Just in time, SpongeBob and Patrick return with the crown and confront Plankton, who then drops a mind-control bucket on Neptune, enslaving him. SpongeBob performs the song “Goofy Goober Rock” (performed by Jim Wise) and, after transforming into an electric guitar-wielding wizard for the duration of the song, he frees Bikini Bottom’s residents. Plankton is arrested, and King Neptune thanks SpongeBob for his bravery and thaws Mr. Krabs, who makes SpongeBob manager of the Krusty Krab 2 in gratitude.