Ash and Pikachu are sleeping in Professor Kukui's house when Ash wakes up, looks at his Z-Ring, and remembers his battle with Tapu Koko, where his Electrium Z shattered. Rotom goes to wake him up but notices in surprise that Ash is already awake. During breakfast, Ash explains to Professor Kukui that he wants to have a rematch with Tapu Koko and try Z-Moves again. Ash remembers that he could obtain Z-Crystals by going through the island challenge which Professor Kukui confirms is one way but the most certain way. Ash gets excited when Rotom explains that he will have to defeat the Kahuna in a grand trial, after clearing smaller trials first. Seeing Ash's determination, Professor Kukui suggests they first pay Hala a visit as Kahuna of Melemele Island.
Elsewhere, a large group of Alolan Rattata and Alolan Raticate are eating fruit in a field, until they get confronted by the owner. However as they run off, they end up startling three Tauros pulling a cart of timber, sending the timber flying. Along the road, Professor Kukui, Ash and Rotom are walking when they spot several villagers in a hurry, and then notice the accident that had occurred with the Tauros. Officer Jenny informs the villagers that the road has been closed until the timber can be cleared. A man and his Hariyama then arrive and start picking up the timber. Ash notes that the man is strong as Professor Kukui introduces Ash to Hala. Ash also goes to help pick up the logs of wood, but finds it too heavy to lift. Four Machamp arrive on scene as part of the clean up crew and work together to quickly clear the timber. After it has all been cleared, Ash tells Hala that he is here for the Island Challenge, though Hala mentions that he had already known, and invites Ash and Professor Kukui to his house.
The next day, Professor Kukui, Ash and Rotom are at Hala's house and Ash notices a room full of Z-Rings. Hala explains that Ash's Z-Ring is one that he made which surprises Ash as he received it from Tapu Koko. Hala thought this had been the case and explains that he had noticed a Z-Ring was missing and realized it was the work of Tapu Koko. Hala notes that this was the first time it had ever happened and that Tapu Koko appears to have a strange interest in Ash. Noticing Ash's desire to obtain a Z-Crystal, Hala decides to set Ash a question, and asks Ash what he would do to drive out the group of wild Rattata and Raticate causing trouble on the island. Ash responds by saying he would use Pikachu and Rowlet and battle them, but Hala interrupts him by asking if he is curious to know why the island challenge had started. Hala goes on to explain that they hadn't been formed to make trainers stronger, but to raise them in a way to protect and love the islands of Alola as well as the people and Pokémon who inhabit them. He then tasks Ash with looking for an answer that won't just lead to battle and gives Ash plenty of time to think of an answer.
The next day at school, Mallow notes that Lillie is now handling the egg with confidence. Ash is visibly mulling over Hala's question in frustration, when the others offer to help him out. Ash thanks them and restates the question, noting that he has to think of answer without using his Pokémon. Lillie suggests if they learn more about Rattata and Raticate, they could come up with an answer. Rotom then brings up an image of Rattata and Raticate and Ash is surprised that they are different from the Rattata and Raticate he had seen before. Rotom continues and mentions that groups of Gumshoos and Yungoos had been brought in chase them off after their numbers grew. The group then exclaim that they had just found the answer.
In a clearing, Team Rocket have escaped from Bewear and are pleased at finally getting away, though Jessie can't help but think of all the food that Bewear had provided. At that moment, the Rattata and Raticate cross their path and send them flying. They are delighted to be blasting off for once, only to be caught mid-air by Bewear who carries them back to its den.
Meanwhile, Ash has suggested his idea to Hala who agrees with Ash and tells Ash that his question had been to actually test Ash to see if he had what it needed to go through the trial. Later, Ash and Hala arrive at Verdant Cavern, and Hala explains that there are several Gumshoos and Yungoos living in the cave who are very strong but there is one Gumshoos who is very strong, called a Totem Pokémon. Hala informs Ash his challenge is to take on the Totem Pokémon in a battle and be victorious. Then, with the aid of the Totem Pokémon, Ash is to chase away the Rattata and Raticate on the island.
Ash is surprised at how huge it is inside the cavern, as Hala calls out to the Totem Pokémon. A Yungoos and a Gumshoos then appear, and Ash learns that they are the Totem Pokémon's allies and that he has to battle them first. Ash asks Rotom for data on Yungoos and Gumshoos, and learns that they are both Normal-types. Ash sends Pikachu to battle and brings out a sleeping Rowlet to assist. After waking Rowlet up quickly, the battle begins with Ash ordering Pikachu to use Thunderbolt and Rowlet to use Tackle. However, Gumshoos blinds them with Sand Attack, preventing their attacks from hitting before launching another attack. After Yungoos and Gumshoos finish their first attack on Rowlet and Pikachu, they immediately follow up with another. Ash commands the two to dodge, and then commands Rowlet to use Leafage, which creates a storm of leaves that not only surround Yungoos and Gumshoos, but also provide Pikachu and Rowlet some cover. Ash commands Pikachu to use Iron Tail and is about to give Rowlet a command before noticing that Rowlet is gone. Both Ash and Hala then notice Rowlet behind Yungoos, and Hala notes that Rowlet is able to fly silently. Seeing Rowlet in a favourable position, Ash commands Rowlet to use Tackle on Yungoos while Pikachu uses Iron Tail on Gumshoos. Both attacks hit their target and manage to knock out the two Pokémon with Hala officially declaring the two Ally Pokémon unable to battle.
Ash and his Pokémon celebrate their victory, but their victory is short lived as they hear heavy footsteps from the deeper parts of the cavern. The footsteps reveal to be the Totem Pokémon Gumshoos, and Ash is shocked at how big it is. Rotom notes that it is three times the size of a normal Gumshoos. The Totem Gumshoos lets out a loud roar and as this happens, Tapu Koko flies past to observe the battle, unnoticed by those in the cavern. The Totem Gumshoos leaps into the air towards Pikachu to which Ash responds by ordering Pikachu to use Thunderbolt. But before Pikachu attacks, the Totem Gumshoos uses Frustration at Pikachu. However the Mouse Pokémon dodges the attack, albeit barely and counterattacks with a Thunderbolt which successfully hits Gumshoos. But Gumshoos manages to shrug off the attack and attacks again with Frustration, but this time it manages to hit Pikachu. This sends Pikachu flying and Gumshoos immediately appears behind Pikachu preparing for another attack.
Ash then notices Rowlet flying behind Gumshoos and commands Rowlet to use Tackle from behind. But just as Rowlet is about to hit the Totem Pokémon, it picks up a nearby rock and throws it at Rowlet, sending it flying at Ash who barely manages to catch Rowlet in time. It is then shown that Rowlet has been knocked out unable to battle. Ash then commands Pikachu to use Electro Ball while the Totem Gumshoos uses Sand Attack in response to intercept the attack. Pikachu watches in shock as his attack gets deflected, allowing Gumshoos to hit Pikachu from behind and send him flying across the battlefield. Ash then orders Pikachu to use a Quick Attack, but as Pikachu begins to charge towards Gumshoos, Gumshoos responds with Sand Attack. However, Ash tells Pikachu to use the sand as its own cover. Pikachu runs directly into the sand and then begins circling around Gumshoos, spreading the sand to create a thick dust cloud which disorientates the Totem Gumshoos. Pikachu then strikes the Totem Pokémon with a barrage of Quick Attacks. This causes Gumshoos to fall to the ground, and Ash commands Pikachu to finish it off with a Thunderbolt. However, Gumshoos manages to break out of the Thunderbolt, and appears to be about to continue battling. But instead, the Totem Pokémon collapses to the ground unable to battle. Hala announces that the trial has finished and that the official winner is Ash. Ash runs up to Gumshoos to see if it is okay. The Totem Gumshoos brushes Ash off, but at the same time shows him a white Z-Crystal. Ash asks if it is for him but the Totem Gumshoos thrusts its paw towards Ash to reply affirmative. Hala then expresses surprise that Ash has received a Z-Crystal directly from a Totem Pokémon; something that is a very rare occurrence. As this is all happening, Tapu Koko flies away. Ash then asks the Totem Gumshoos if it could help him with the problem involving Alolan Rattata and Raticate, and the Totem Gumshoos grins in response.
Later in a supermarket storage room, a large group of Rattata and Raticate burst out of boxes containing fruit and begin eating all the food inside. Outside the room, Ash, Professor Kukui, Hala, Officer Jenny and the Totem Gumshoos and ally Gumshoos and Yungoos all prepare to ambush the Alolan pests. Professor Kukui alerts everyone that he and Officer Jenny are opening the doors and the moment they do, the Rattata and Raticate stop eating to stare in surprise at seeing the Pokémon they fear the most. The group of Alolan Rattata and Raticate then charge at the two Gumshoos and Yungoos. However their efforts of fighting are in vain as the Rattata and Raticate were sent flying in large numbers as the Gumshoos and Yungoos unleash their attacks. The Alolan Rattata and Raticate then flee back into the wild as the two Gumshoos and Yungoos cry out in victory. Hala then approaches Ash and as Island Kahuna, officially recognizes Ash as having completed the trial. Hala says that Ash has the Grand Trial up next for him and says that he is excited to battle Ash.