Beans discovers that the water reserves, stored in a water-cooler bottle in the bank, are dangerously low. At the saloon, the chameleon, using bravado, presents himself as Rango, a tough drifter. He quickly runs afoul of outlaw Bad Bill (Ray Winstone), narrowly avoiding a shootout when the hawk returns, scaring Bill. The hawk chases Rango until by luck Rango kills the predator by crushing it under an empty water tower he's accidentally made collapse. In response, Mayor Tortoise John (Ned Beatty) appoints Rango the new sheriff. A skeptical Beans demands Rango investigate the water problem while the townsfolk fret that the hawk was the only thing keeping gunslinger Rattlesnake Jake from returning to terrorize them.
That night, Rango inadvertently gives some mole robbers the location of the bank and tools to break into the vault. When the townsfolk find their water stolen, Rango organizes a posse that finds bank manager Merrimack (Stephen Root) dead. They eventually track the robbers to their mountain hideout, only for their leader, Balthazar (Harry Dean Stanton), to reveal that his clan of moles, prairie dogs and others greatly outnumbers the posse. Nabbing the covered wagonwater-bottle, the posse flees, chased in a ground and air fight before discovering the bottle is empty. Despite the robbers professing that they'd discovered it empty, the posse returns them to town for trial.
After Rango and Beans deduce that the Mayor has been buying all the nearby land around, Rango recalls the mayor telling him how controlling water equals control of everything. He confronts the mayor, who denies he has done anything wrong and shows Rango that he is building a modern city on the old land. With no proof of the mayor's wrongdoing, Rango leaves, while the mayor orders one of his men to call Rattlesnake Jake (Bill Nighy) — who soon arrives, firing shots with his gatling gun tail, and recognizing that Rango is a fake. Jake runs him out of town after humiliating him and making him admit that everything he told the town about himself is a lie.
Ashamed and no longer knowing who he is, Rango wanders the desert and in a daze meets the Spirit of the West (Timothy Olyphant), a cowboy whom Rango calls the Man with No Name. The Spirit inspires Rango and tells him, "No man can walk out on his own story." With the aid of the armadillo and mystical moving cacti, Rango learns the source of Dirt's water is Las Vegas, and that someone has shut off a water line. Realizing the mayor's hand in this, Rango recruits the hill clan in his plan.
Returning to town, he calls out Jake for a duel — a diversion so that the hill folk and the cacti can flood the town with water. The mayor threatens Beans' life, forcing Rango to surrender. The two are put into the water bottle to drown, while the mayor prepares to shoot Jake, whom he calls a relic. Beans and Rango use a bullet to break the tank, flooding the room and taking out the mayor and his men. Jake, acknowledging Rango as a worthy opponent, grabs the mayor and drags him into the desert to take his revenge. The citizens of Dirt celebrate the return of the water.