Arriving in a new town, Ash and his friends spot two children run by dressed as Pumpkaboo and Gourgeist, and upon reaching the Pokémon Center are surprised to see Nurse Joy and Wigglytuff dressed as each other. Nurse Joy explains that the town is celebrating its Gourgeist Festival, where people and Pokémon wear costumes for fun. The gang decide to join in the festivities, with Serena making costumes for everyone. Elsewhere, Team Rocket have also put on costumes, remarking that the festival is a perfect opportunity to steal Pikachu since they guessed the twerps couldn't resist participating. Far away, a short, squat man and his Pumpkaboo observe Jessie's Pumpkaboo to their delight. The man orders his steward to have Team Rocket's group brought to him immediately.
As they walk about, Ash and company learn from the two children they saw earlier that in addition to dressing up, trading treats is a part of the festival as well. Serena trades some of her homemade treats for the children's candy, and the group resolves to do as much trading as possible. Meanwhile, before they can commence their plan to catch Pikachu, Team Rocket finds themselves cornered in an alleyway by three Gourgeist. The steward from earlier, revealing to own them, has the Gourgeist stand down and apologizes, extending his master's invitation to them for a sumptuous dinner. Team Rocket decide to accept the offer and catch Pikachu later.
In the man's castle atop a hill, he introduces himself as Count Pumpka, and reveals the reason why he invited Team Rocket: his Prince Pumpkaboo fell in love with Jessie's Pumpkaboo, who he refers to as a very rare specimen. James confirms that Pumpkaboo come in different varieties of size, and Jessie's Pumpkaboo is a female of the Super Size variety, which Jessie apparently was never aware of. Jessie decides to use the situation to her own benefit by telling Count Pumpka that Pumpkaboo is being pursued by Ash's group, who previously stole Pikachu, and asks Count Pumpka to apprehend them and retrieve Pikachu. Surprised, Count Pumpka agrees and sends his steward away. In the streets, Ash's group encounters the steward who demands Pikachu, sending out his Gourgeist when Ash refuses. Pikachu, Pancham and Bunnelby try to put up a fight, but are soon knocked over. Under the guise of a smokescreen, the steward leaves with Pikachu. To the gang's shock, Pikachu has been left behind - but Chespin, who had a Pikachu costume on, has gone missing!
Back in the castle, Team Rocket is pleased that Pikachu has been caught and presented, not realizing that it's actually Chespin. Count Pumpka states that since he met Jessie's demands, it's now time for her to hold up her end of the bargain: he wants Jessie to trade Pumpkaboo to him so the two Pumpkaboo can marry! Jessie is stunned, quickly indicating her reluctance to trade Pumpkaboo away since they have a great bond together. At this point Ash and company show up to demand Chespin, having found Team Rocket via Fletchinder, but Count Pumpka traps them in an electrified cage after they defeat his steward's Gourgeist. Count Pumpka offers a Mawile to Jessie in trade, reminding Jessie that Mawile is one of the few Pokémon who can undergo Mega Evolution; excited by the idea of owning a Mega Mawile, Jessie agrees to the trade. Pumpkaboo is outraged, more so since Jessie had said so many great things about their relationship only moments ago, and floats over to the enamored Pumpkaboo. James and Meowth are bemused at the display of affection between the two females. Silently, Jessie trades Pumpkaboo away via a trading machine Count Pumpka arranged for, while Clemont attempts to disable the electrified cage.
Happily, Count Pumpka releases his new Pumpkaboo, but Pumpkaboo instantly evolves into Gourgeist, shocking Jessie. Count Pumpka remarks the exchange must have triggered Gourgeist's evolution, but to his dismay his own Prince Pumpkaboo is intimidated by the new Super Size Gourgeist and indicates its displeasure. Jessie is infuriated by this, going into a tirade about how Gourgeist cared for her during her times of illness and loneliness. Both Trainer and Pokémon embrace each other in tears, apologizing to each other, and Jessie demands that Gourgeist be traded back since Count Pumpka no longer has any reason to keep it. Disappointed, Count Pumpka agrees, and Gourgeist is traded back in short order to Jessie and Gourgeist's delight.
Team Rocket prepares to leave, but Bonnie points out that they still have Chespin! She identifies Inkay as a fake Pikachu, and manages to pull off Meowth's Banette costume. Exposed, Team Rocket pull off their disguises; Ash identifies Team Rocket as the actual criminals, much to Count Pumpka and his steward's horror. Jessie sends Gourgeist into battle, but Pikachu manages to deflect all its attacks, and Bunnelby counters inkay's moves. Pikachu and Braixen send Team Rocket blasting off with a combined attack, though Jessie is still happy to be reunited with her beloved Gourgeist, while James and Meowth are content that their friends are happy.
Clemont reunites with Chespin, while Count Pumpka apologizes to Ash's group for the trouble he inadvertently caused, inviting them as guests. On the castle balcony, Ash and friends are served with soup in pumpkin bowls, with Gourgeist's face cut into them. As they eat, a fireworks display is held, which Count Pumpka explains is a tradition to end the festival. The episode ends with the group admiring the fireworks.