In early 20th-century Maine, Pete (Sean Marshall) is fleeing his adoptive family, the Gogans, who mistreat him and use him as a slave. As family matriarch Lena Gogan (Shelley Winters) and company attempt to lure him back ("The Happiest Home in These Hills"), an unseen force, which Pete calls Elliott, distracts the Gogans by knocking Willie (Jeff Conaway) and the rest of the family into the mud. Frustrated, the Gogans resume their search elsewhere, since they spent their savings on "buying" Pete and can't afford to adopt another orphan.
The next morning, Pete and Elliott, who is revealed to be a large green and purple dragon, share breakfast in an apple orchard ("Boo Bop BopBop Bop (I Love You, Too)"). The pair decide to go to a nearby fishing village, Passamaquoddy. Unfortunately, the unseen Elliott makes his presence known by knocking over things and making footprints in wet cement. Pete is immediately labeled a source of ill luck and is forced to flee. Nearby, Lampie (Mickey Rooney) stumbles out of a tavern and encounters Pete. Elliott decides to make himself visible and playfully scare Lampie, much to the disgust of Pete. Panicked, Lampie runs back into the bar to warn the townsfolk, who take his rantings as a drunken delusion ("I Saw a Dragon"). Nora (Helen Reddy), Lampie's headstrong daughter, comes looking for him and gets swept up in the tavern's lampooning. Nora takes Lampie back to their home, the Passamaquoddy lighthouse, and settles him down. After putting Lampie to bed, she spies a young boy, Pete, walking along the beach and decides to investigate.
Pete and Elliott sit in a cave near the lighthouse, where Pete rebukes Elliott for causing trouble and worries about his own future. The two make up just as Pete is discovered by Nora, who invites him into the lighthouse for the night. There, he explains his history and how Elliott rescued him from the Gogans ("It's Not Easy"). As they talk, Pete sees a picture of a sailor and asks who it is. Nora explains that it is her fiancé Paul, whose ship has been missing for a long time. Pete tells her that he will ask Elliott about Paul, because he [Elliott] has a way of knowing things. Nora believes Elliott to be an imaginary friend, and that Pete is trying to cheer her up, so she pretends to believe that Elliott will help her.
Doc Terminus (Jim Dale), a snake-oil salesman, and his shill Hoagie (Red Buttons), fleeing from pursuers, arrive in Passamaquoddy. The town's population, who have been visited by Terminus before, are initially angered by his return. But, thanks to his clever salesmanship, Terminus is able to calm the mob ("Passamashloddy") and sets up shop to sell more of his wares. Meanwhile, Nora has taken Pete to buy some new clothes. That evening, Pete asks to go to the cave to show Elliott his new suit and to take Paul's picture so Elliott can help find him. Both agree, with Lampie adding that Elliott isn't allowed in the lighthouse. Nora thanks her father for pretending that the dragon exists, but Lampie insists he actually saw a dragon. Nora tells him to be realistic, to which Lampie retorts that Nora has been holding out hope for Paul's return, something nobody else expects to happen. Lampie apologizes for his outburst and excuses himself, giving Nora time to think ("Candle on the Water").
As Terminus and Hoagie "treat" the townsfolk in the tavern, Lampie drunkenly stumbles up and tells them both about the dragon. Terminus dismisses the tale, but Hoagie, just as drunk as Lampie, agrees to go with Lampie to the cave. In the cave, Elliott observes the duo as they frighten themselves with exaggerated descriptions of a terrifying monster. Fearful himself, and not realizing they are describing him, Elliott joins them as they explore, to the shock of Hoagie and Lampie. After all three face each other, Hoagie offers Elliott some liquor as a gesture of peace. The alcohol, however, triggers a fiery belch from his mouth that chases both men out of the cave.
Nora escorts Pete to school, while the local fishermen complain about the recent scarcity of fish, and upon seeing Pete believe he is the cause. Nora angrily reminds them the fishing grounds shift at times, and that "There's Room For Everyone" in town, even Pete and his "dragon." At the schoolhouse, Miss Taylor is wary of accepting Pete as a new student, but relents. During the lessons, the invisible Elliott begins ringing the school bell. As Pete tries to stop Elliott, Miss Taylor sees Pete on the bell's rope and thinks that he is ringing it. Miss Taylor punishes Pete for lying, which enrages Elliott, who smashes into the building, leaving dragon-shaped holes in the walls. Doc Terminus, hearing the ruckus, sees the damage and realizes the dragon is quite real. He discovers that dragons have a lot of uses ("Every Little Piece") and hatches a plot to buy Elliott from Pete.
At the lighthouse, Terminus makes Pete an offer for Elliott, which Pete refuses since he doesn't "own" Elliott. The two crooks are subsequently chased away by Nora's foghorn. Afterwards, Nora reveals to Pete that she and Lampie would like for Pete to stay with them, so that Pete can "stop running" and live a normal life. Gratefully, Pete accepts their offer ("Brazzle Dazzle Day"). Unfortunately, the Gogans arrive in Passamaquoddy, still searching for Pete. They ask Hoagie if he knows a Pete, one that always talks about a dragon. Nearby townsfolk react to the question, telling them this is where Pete is. The Gogans find Pete with Nora and Lampie by the wharf ("Bill of Sale"), but Elliott arrives in time to save the day. Terminus later visits the Gogans, convincing them that he will give them Pete if they help him capture Elliott. He then gathers allies among the superstitious who take the dragon as a sign of misfortune and prepares a trap.
That evening, a storm starts to blow in. Elliott tells Pete he has located Paul. Pete tries to tell Nora the good news; however, Nora, still believing that Pete has made up Elliott, says that since Pete has a new home, it was time both of them became more realistic so they could move on. Even Lampie begins to doubt that he saw a dragon. Pete, however, is largely undeterred, and he helps Nora prepare the lighthouse for the storm. Out at sea, a sailing ship is heading for Passamaquoddy. The ship's captain is assisted by none other than Paul, who knows the local waters, as well as the lighthouse-keepers.
Terminus comes to the lighthouse and lures Pete to the town's boathouse, while the frightened Hoagie does the same to Elliott. At the boathouse, Elliott discovers Pete just as Terminus springs his trap. Elliott is able to break free and rescues Pete from the Gogans before they can escape. In a last effort, Lena Gogan shows Elliott the bill of sale that declares her Pete's legal guardian. Elliott sets the paper on fire, tips Lena Gogan into a barrel of creosote, and chases off the family's carriage horse. As Pete and Elliott celebrate, Terminus aims a large harpoon gun at the distracted dragon. He is about to fire when he realizes that the harpoon's rope is looped around his ankle. He diverts the cannon, but is unable to stop it from shooting him through the ceiling. The harpoon lands in a pole, leaving Terminus dangling and, with his wagon destroyed, out of business. As they prepare to leave, Elliott sees a utility pole start to fall towards the town hall, just as the mayor, Miss Taylor and the town council are exiting. Elliott, now visible, catches the pole and saves them, much to their surprise.
Off the coast, a ship is headed for the jagged rocks of a reef. The Passamaquoddy lighthouse has been hit by a monstrous wave that shattered the lantern room windows, drenching the oil-burning lamp, and Lampie cannot find a dry wick. Elliott arrives just in time to light the lamp with his own fire. As he is trying to do so, Nora comes in and is astonished by his presence. After several failures, the light is ignited and the ship is saved.
The saving of the ship enables Elliott to become accepted by the townspeople as a heroic figure or guardian. The economy prospers, and the mayor is humbled. Nora's love Paul returns, the sole survivor of the wreck of which Nora was informed earlier. It is revealed that Paul had lost his memory until an intervention by Elliott restored it, and shown that he was aboard the ship saved during the previous night.
Elliott, however, has sad news: because Pete is now safe and has a loving family of his own, the dragon must move on to help other children. Pete and Elliott say their goodbyes, and Elliott flies off to his next task, with Pete reminding him to remain invisible. A reprise of the line "There really is a dragon" is provided by Paul.