In a Lego world populated by anthropomorphic minifigures, the evil Lord Business finds a super weapon called the "Kragle". The wizard Vitruvius attempts to stop him, but is blinded by Business' robots; he prophesies that a person called "the Special" will find the Piece of Resistance, a brick capable of stopping the Kragle.
8½ years later, construction worker Emmet Brickowski finds a woman named Wyldstyle searching for something at his construction site after hours. When he investigates, Emmet falls into a hole and finds the Piece of Resistance. Compelled to touch it, Emmet experiences vivid visions and passes out. He awakens with the Piece of Resistance attached to his back, in the custody of Bad Cop, Lord Business's lieutenant. Wyldstyle rescues Emmett, believing him to be the Special, and takes him to meet Vitruvius in the Old West. Emmet learns that Wyldstyle and Vitruvius are "Master Builders"—people capable of building anything from their imagination without the need of instructions—who oppose Business. Wyldstyle explains Business wants to use the Kragle, a tube of Krazy Glue with a weathered label, to freeze the world into perfection. Though disappointed to find Emmet is not a Master Builder, Wyldstyle and Vitruvius are convinced of his potential when he recalls visions of a seemingly human deity referred to as "the Man Upstairs".
Emmet, Wyldstyle, and Vitruvius evade Bad Cop's forces with the aid of Batman, Wyldstyle's boyfriend. They go to the hidden Cloud Cuckooland where they attend a council of Master Builders, who are unimpressed with Emmet and refuse to fight Business. Bad Cop's forces attack, having placed a tracking device on Emmett, and capture everyone except Emmet and a small team of Master Builders. Escaping, Emmet devises a plan to infiltrate Business's office tower and disarm the Kragle, but the group is captured and imprisoned in the Think Tank, where all the Master Builders are forced to make instructions. Trying to retaliate, Vitruvius is decapitated by Business, who sets a self-destruct protocol and leaves everyone to die, including Bad Cop. As he dies, Vitruvius reveals he made up the prophecy. He soon reappears to Emmet as a ghost and tells him that his belief makes him the Special. Strapped to the self-destruct mechanism's battery, Emmet jumps into the abyss outside the tower and severs the connection, saving his friends. Inspired by Emmet's sacrifice, Wyldstyle rallies the Lego people across the universe to use whatever creativity they have to build machines and weapons to fight against Lord Business's forces.
Emmet finds himself in the human world as a Lego minifigure unable to move. The events of the story are being played out by a little boy named Finn on his father's expansive Lego set in their basement. His father—"the Man Upstairs"—comes home from work and chastises his son for ruining the set by creating variations of different playsets, and proceeds to permanently rebuild and glue his perceived perfect creations together. Realizing the danger his friends are in, Emmet wills himself to move and gains Finn's attention. Finn returns Emmet and the Piece of Resistance to the set, where Emmet now possesses the powers of a Master Builder and confronts Business. Meanwhile, Finn's father looks at his son's creations and realizes that Finn had based the villainous Business on him and his perfectionism. Through a speech Emmet gives Business, Finn tells his father that he is special and has the power to change everything. Finn reconciles with his father, which plays out as Business having a change of heart, capping the Kragle, and ungluing his victims with mineral spirits. Emmet is hailed as a hero, and begins a relationship with Wyldstyle with Batman's blessing.
As a result of Finn's father allowing Finn's younger sister to join them in playing with his Lego sets, aliens from the planet Duplon beam down and announce their plans to destroy them.