A pet chameleon (Johnny Depp) becomes stranded in the Mojave Desert after his terrarium falls from his owners' car by accident. He meets an armadillo named Roadkill (Alfred Molina) who is seeking the mystical "Spirit of the West" and directs the parched chameleon to find water at a town called Dirt. While wandering the desert, he narrowly avoids being eaten by a vicious red-tailed hawk and has a surreal nightmare before meeting the desert iguana Beans (Isla Fisher), a rancher's daughter, who takes the chameleon to Dirt, an Old West town populated by desert animals.
Meanwhile, after the battle of Chicago, Brian and the Eeveelutions are relived that the robot war is over, and they discovered Dirt and decided to head down there.
Using bravado and improvisation to fit in, the chameleon presents himself to the townsfolk as a tough drifter named Rango. He quickly runs afoul of outlaw Gila monster Bad Bill (Ray Winstone), but avoids a shootout when Bill is scared off by the hawk's return. Rango is chased by the hawk until he accidentally knocks down an empty water tower which crushes the predator. In response, the town mayor, an elderly tortoise named Tortoise John (Ned Beatty), appoints Rango the new sheriff. Meanwhile, the townsfolk worry that with the hawk dead, the gunslinger Rattlesnake Jake (Bill Nighy), who is afraid of hawks, will return.
After discovering Dirt's water reserves — stored in the town bank inside a water cooler bottle — to be near empty, a skeptical Beans demands Rango investigate where all the water has disappeared to. That night, however, Rango inadvertently assists a trio of bank robbers, led by a mole named Balthazar (Harry Dean Stanton), mistaking them for prospectors. The townsfolk find their water bottle stolen the next day, so Rango organizes a posse. They discover bank manager Merrimack (Stephen Root) dead in the desert having somehow drowned despite the towns lack of water, and track the robbers to their hideout. They fight the robbers' clan over the stolen water bottle in a chase through a canyon before discovering the bottle to be empty. Despite the robbers professing they had found it empty, the posse brings them to town for trial.
Rango confronts the mayor about his buying of the land around Dirt, who denies any wrongdoing and shows Rango that he is building a modern city with the purchased land. The mayor summons Rattlesnake Jake, who runs Rango out of town after humiliating him and making him admit that everything he told the town about himself is a lie. Rango wanders away ashamed and confused about his identity. Finally, he meets the Spirit of the West (Timothy Olyphant), whom Rango identifies as the Man with No Name. The Spirit inspires Rango, telling him, "No man can walk out on his own story."
With the aid of Roadkill and mystical moving yuccas, Rango learns that Dirt's water supply is controlled by an emergency shut-off valve in a water pipeline to Las Vegas, which the mayor has been manipulating to cause a drought so he could buy the land. Recruiting the robbers' clan to aid him, Rango returns to Dirt to call out Jake for a duel with a single bullet, a diversion so the clan and yuccas can turn the pipeline's valve to flood the town with water and free the falsely accused robbers. The mayor, however, forces Rango to surrender by threatening Beans' life, and locks them inside the glass bank vault to drown. He then tries to shoot Jake with Rango's gun, believing that Jake is still part of the Old West that the mayor wants to destroy along with the rest of the town. The mayor is shocked to discover that the gun is empty; Rango has taken the bullet, which he uses to crack the glass and shatter the vault, freeing himself and Beans while washing the Mayor and his men away outside. Impressed, Jake tips his hat to Rango as thanks for saving his life and drags the mayor into the desert to kill him in revenge for double-crossing him. The citizens of Dirt celebrate the return of the water and recognize Rango as their hero.