While performing on Lake Springfield, the band Green Day perishes when the lake's pollution dissolves their barge, following an audience revolt after frontman Billie Joe Armstrong proposes an environmental discussion. At their memorial, Grampa foresees the destruction of the town, but only Marge takes this seriously. Later that day, Homer dares Bart to skateboard naked to Krusty Burger and Bart is arrested by Chief Wiggum. Bart considers their neighbor Ned Flanders a better father figure after Homer refuses to take responsibility for the incident. Lisa and a new Irish friend named Colin convince the entire town to clean their lake.
Meanwhile, Homer adopts a pig from Krusty Burger and names it "Spider Pig" (later "Harry Plopper", and simply "Plopper"), and stores the pig's feces (and some of his own) in a silo, until Marge tells him to safely dispose of the waste. Homer initially intends to take his silo to the waste management plant, but after Lenny calls to tell him that Lard Lad Donuts has been shut down due to health violations and is giving away free donuts, Homer impatiently dumps the silo straight into the lake, polluting it much worse than before. Moments later, a squirrel jumps into the lake and becomes severely mutated; Flanders and Bart (who bond after Homer humiliates Bart) discover the creature before the EPA captures it. Russ Cargill, head of the EPA, presents five "unthinkable" options to U.S. President Arnold Schwarzenegger to keep the town's pollution contained. The slow-witted president picks option 3 without reading it, and Springfield is enclosed in a large glass dome. When the police discover Homer's silo in the lake, and his responsibility for sealing Springfield in the dome, the townspeople of Springfield except for the Flanders family form an angry mob and advance on the Simpsons' home to kill Homer, but the family escapes the town through a sinkhole, which then destroys their house. With the EPA on their trail, the Simpsons flee to Alaska. On the way, Homer tries to make some money at a carnival by riding a motorcycle around the inside of a metal cage, which he accomplishes with the aid of Lisa.
After three months of futile escape attempts, Springfield's residents finally make a crack in the dome; pointing out the damage, Cargill manipulates Schwarzenegger into ordering the town's destruction. In Alaska, the Simpsons see an advertisement starring Tom Hanks for a new Grand Canyon on the site of Springfield; realizing the town is endangered, Marge and the children want to go back to save it, but Homer refuses to help the people who tried to kill him. After failing to talk Homer into it, his family eventually leave him for good. Alone, Homer is stranded on an iceberg and floats away. Meanwhile, Marge and the children are captured by the EPA after a conversation of theirs is overheard by the NSA. After a mysterious Inuit shaman saves him from a polar bear, Homer has an epiphany and decides to return to Springfield to save the town from danger.
As Homer arrives, a helicopter lowers a small but powerful bomb down a rope through a hole in the dome. While Homer climbs to the top of the dome, the townspeople attempt to climb the rope to escape through the still-opened hole, but Homer slides down the rope and knocks them off along with the bomb. After reconciling with Bart, Homer drives a motorcycle along the dome, inspired by the earlier carnival attraction. As a passenger of the motorcycle, Bart throws the bomb through the hole; seconds later it detonates, shattering the dome and freeing the town. Cargill arrives personally and prepares to kill Homer with a shotgun, but Maggie kills him with a boulder. The town finally praises and forgives Homer, who rides into the sun rise with Marge and Maggie, whereupon the townspeople restore Springfield to normal. As a symbol of their gratitude, the Simpsons and their friends begin to rebuild the family's house.