Aang, Katara, Sokka, Appa, and Momo are sleeping, when Momo finds a spider has spun a web in Sokka's open mouth, but when he snatches the spider and its web, he wakes up an irate Sokka in the process. Soon after that, the rest are awakened by four Fire Nation men on rhinos who surround them and begin to attack them. Upon trying to escape, Sokka is forced to abandon his boomerang, which makes him very upset.
While buying produce from an Earth nation man, Sokka laments on how losing his boomerang amounts to losing his identity. After happily accepting Katara's Water Tribe money and giving the group their produce, the man wishes them a Happy Avatar Day and asks if they are going to the Avatar Day festival in the nearby village. After arriving at the village, they see giant paper floats of Avatar Kyoshi, Avatar Roku, and Aang brought to the town square. A short time later, a man with a torch runs up to the first two floats and sets them on fire. To the trio's dismay, the townspeople begin to chant "Down with the Avatar!"
Meanwhile in another Earth Kingdom city, a couple carrying food is robbed by Zuko in his Blue Spirit costume. After hiding his mask, he gives the food to Uncle Iroh. Iroh is suspicious of the source of the food, but enjoys it anyways.
At the festival, the Mayor Tong signals to the man, who throws the torch at Aang's float. Katara runs up to the floats and uses her waterbending to put out the fires. As the people begin to complain, Aang leaps to the top of his float and reveals himself. The people become fearful, thinking that the Aang has come to kill them but he and Katara try to persuade them that the Avatar helps people. The Mayor then tells that over 300 years ago, Avatar Kyoshi killed their leader, Chin the Great.
In an effort to clear the Avatar's name, Aang agrees to follow the town's laws, which include standing trial (and awaiting his trial in jail, on bail). Unfortunately, they don't accept Water Tribe money. When Sokka insists that Aang use his airbending to escape jail, Aang refuses and asks for Sokka and Katara's help in clearing his name. Sokka is then convinced to become a detective. After donning a funny hat with a magnifying glass on the brim, he gets to work on the case.
On a forest road, a rich Earth Kingdom noble is traveling with a chest full of gold. When the driver is attacked, he cowers in fear and locks the chest. Zuko (in his Blue Spirit costume) cuts a hole in the roof and takes the chest.
Katara and Sokka examine the cliff, where Avatar Kyoshi supposedly killed Chin the Great. The Mayor says that Avatar Kyoshi emerged from the temple and struck down Chin, and afterwards they built a statue of him to commemorate him. Sokka observes that the statue and the temple are made from the same stone and that they were built at the same time. When Katara tries to help him get to the point, Sokka yells at her, claiming that it's his job to come to the conclusion: Avatar Kyoshi never set foot in the temple. Sokka decided that he and Katara need to go to Kyoshi Island for more proof.
In jail, Aang meets another one of his cellmates, a bald man with tattoos. He charges at Aang, but the chain and collar on his neck keep him at bay. He tells Aang creepily that he will fit in nicely in the jail cell.
When Katara, Sokka, Momo and Appa arrive at Kyoshi Island, the natives flock with excitement, but soon leave in disappointment when they learn that Aang's not with them. They greet Oyaji, the village leader and tell of Aang's plight and he offers to take them to Kyoshi's shrine. On the way to the shrine Sokka asks about Suki, the leader of the female warriors of Kyoshi who he had befriended before. Oyaji tells that after their visit, Suki and the other warriors felt inspired to go and help fight in the war. They reach the shrine and go inside.
Inside a room in the shrine, Oyaji displays some of Kyoshi's old things. After seeing Kyoshi's boots, Katara remembers the footprint at the tip of the cliff where Kyoshi was said to have stood. Before she can express her revelation, Sokka insists that since he is the "detective" he make it instead: the Kyoshi's feet were too big to make that footprint.
Back in the jail we see that Aang has befriended all of the inmates, who proceed to give him advice on his relationship with Katara. Even though he is unsure, they reassure him that he's smart, handsome, funny, and the Avatar. One teary-eyed inmate encourages Aang to tell Katara how he feels.
Back at Kyoshi, Oyaji shows Sokka and Katara a painting of the day that Kyoshi Island was founded. It was painted on sunrise on the same day 370 years ago to the present day. After noticing the position of the shadows of the people in the painting, Sokka (after pushing Katara to beat her to the punch) says that since Kyoshi was on Kyoshi Island at sunset then she couldn't have been at Chin committing the crime. The two return to Chin, and tell Mayor Tong that they have a solid defense for Aang built on good evidence. The mayor then tells them that the way the trial goes is that he tells what happens, and then they tell what happens, and then he decides what's right: justice, or "just-us" he claims.
At the trial on the next day, the Mayor gives his biased account on what happened, and then proceeds to let Aang give his story. Aang displays a feeble attempt to memorize the evidence that Sokka and Katara have gathered. Sokka and Katara agree that Aang's dead.
Back at their hideout in the forest, Uncle begins to wonder about the new things that Zuko is bringing every day. He tells Zuko that there is nothing shameful about having nothing, and to keep hope that he will be able to go home one day. Zuko walks off to think about his uncle's words.
At the trial, Katara calls a surprise witness: Avatar Kyoshi! It is then revealed just to be Aang dressed in Avatar Kyoshi's clothes and face paint, which Katara believes will trigger something. Mayor Tong complains that this is a mockery on the city, and prepares to sentence Aang when a giant whirlwind appears around Aang. A shadow appeared over the whole village and the whirlwind disappears to reveal Avatar Kyoshi herself. She then states, "I killed Chin the Conqueror."
She proceeds to tell the tale of Chin, an Earthbender tyrant who waged a campaign to conquer the continent. When he came to the peninsula where Kyoshi and her people lived he ordered her surrender, but she refused. Not backing down, Chin stood poised to fight her, and she replied by using her fans to airbend his clothes off. She then uses her earthbending to form a canyon between them, her firebending to cut off her side with magma, and airbending to blow her side of the peninsula away, creating Kyoshi Island. Chin screams and the cliff he stands on crumbles and drops him into the ocean.
She says that she created Kyoshi Island so that her people could be safe from invaders, and in another whirlwind she vanishes and the shadow is lifted. In light of Kyoshi's amazing testimony, the Mayor still finds Aang guilty, and orders that "The Wheel of Punishment" be brought out.
Zuko comes back and tells Iroh that he thought about what he has said and realizes that they have nothing to gain by traveling with each other. Claiming that he needs to find his own way, he takes his things and leaves. Iroh gives him the riding animal that Zuko stole and sends him on his way.
Aang now has to spin the Wheel of Punishment to determine his sentence. After the wheel lands on "Boiling in Oil", the village is attacked by the same group of rhino-riders from the Fire Nation, or "Rough-Rhinos." They destroy the temple and Chin's statue and demand to see the Mayor, who hides behind the wheel and begs Aang to save them. After Aang explains that he's "supposed to be boiled in oil" Mayor Tong moves the wheel to "Community Service" and tells Aang to serve to community by defeating the invaders. After Aang knocks one of the riders off of the cliff, the rest of the riders proceed to destroy the town.
Katara and Sokka defeat three of the riders and in the process Sokka reclaims his long lost boomerang, which "always comes back". After Aang defeats the leader of the riders, the town decides to change from hating the Avatar to celebrating the Avatar. The three are given the new festival food: un-fried dough cookies shaped like Aang, to remind them on how on that day, the Avatar was not boiled in oil.