SpongeBob and Patrick are running up to the Medieval Moments stadium/restaurant to watch the jousting tournament. Upon their arrival, Morrie announces the tournament and asks for two volunteers to take part in the jousting, choosing SpongeBob and Patrick. Unaware that they are actually going to be in the tournament, and not just watching upclose, they are forced to mount seahorses and start jousting against each other. They are both launched off of their seahorses into the air, and land in a small field in 8th Century Bikini Bottom.
A large group of knights on seahorses surround the duo. They lock SpongeBob and Patrick in the dungeons because they think they are evil. There they see a squid playing a clarinet. They think it is Squidward, but the octopus' name is actually Squidly. In the meantime, SpongeBob and Patrick still think this is part of the Medieval Moments tournament. Because Squidly cannot play the clarinet properly, he cursed his 7th great grandson, Squidward, to not being able to play the clarinet.
SpongeBob still thinks they are in the restaurant, and comments on how authentic the "props" are. Later, SpongeBob, Patrick, and Squidly are sent to King Krabs, who orders them to be executed because of an insulting song they sing in front of him. However, Princess Pearl reminds King Krabs of a prophecy in a stained glass window, which says that two brave knights will fall from the sky and will be sent by a king and defeat the dragon controlled by the evil wizard Planktonamor that is destroying the kingdom. Just then, the Dragon Jellyfish smashes through the wall with the prophecy on it.
Under Planktonamor's orders, it kidnaps Pearl in order to kill her and effortlessly flicks King Krabs into the guillotine, smashing it just before SpongeBob can be executed. The dragon flies away, and King Krabs begs SpongeBob and company to rescue her, treating them like royalty, until seeing a section of the prophecy showing him kicking out SpongeBob and Patrick. He tells them to defeat the dragon, then proceeds to kick them out. However, SpongeBob and Patrick decide to literally kick themselves out, and Squidly comes along as well after orders from King Krabs.
On the way, they stop off at the Blacksmith's shop to get some armor and weapons, only to find that all of the weapons are too heavy except for the jellyfish net. As they reach the bridge to Planktonamor's tower, they are attacked by a Dark Knight, who guards the bridge. The Dark Knight is revealed to be none-other than a medieval Sandy (who, unlike the present Sandy, does not need an air helmet). A duel ensues, with SpongeBob ultimately winning due to his karate prowess. After the battle, SpongeBob decides to spare her life. Amazed, the Dark Knight decides to follow SpongeBob, Patrick, and Squidly on their quest (and learn a trifle of Karate, according to her).
Back at the King's castle, Krabs receives a note saying that Princess Pearl will die if he does not hand over the village and his throne. SpongeBob, Patrick, Squidly and the Dark Knight make an incredibly long journey to the top of the tower, where SpongeBob distracts Planktonamor while Patrick, Squidly, and the Dark Knight try to rescue Pearl.
However, the Dragon soon arrives and manages to zap the heroes. Just as the Dragon is about to finish off SpongeBob, he pulls out a Krabby Patty he had been saving for lunch. The Dragon eats it and likes it so much that it becomes obedient to SpongeBob, zapping Planktonamor. The heroes return to the village to have their victory celebrated, and King Krabs is seen cooking Krabby Patties (on a modern grill) for the dragon. However, as soon as Squidly starts playing his clarinet, everybody hates it, and someone throws a rock at him. The seahorses become scared and launch SpongeBob and Patrick into the air.
They land back at the tournament in present day, and SpongeBob says, "I guess I shouldn't have agitated that Seahorse. That was some dream I had, eh Patrick?" Patrick then replies, "Try telling that to Squidly." He then stands up, revealing a horribly squashed Squidly underneath him. Then Squidly makes makes a note on his clarinet.
On the Season 4, Volume 1 DVD, the storyboard shows SpongeBob and Patrick making sure they are ok after falling out of the sky.