Over Gotham City airspace, two best friend pilots are transporting an insane amount of explosives. They are hijacked by The Joker (voice of Zach Galifianakis) and his minions. Across the city, Joker has set loose some of Gotham's most notorious criminals, including Harley Quinn (voice of Jenny Slate), Two-Face (voice of Billy Dee Williams), The Riddler (voice of Conan O'Brien), Scarecrow (voice of Jason Mantzoukas), Catwoman (voice of Zoe Kravitz), Poison Ivy (voice of Riki Lindhome), Clayface (voice of Kate Miccuci), Bane (voice of Doug Benson), Mr. Freeze, The Penguin, and some C-list villains like Calendar Man, Gentleman Ghost, and Condiment King. The pilot knows Batman (voice Will Arnett) will stop Joker, but he believes otherwise. Beneath the city's central core, Joker has Killer Croc plant a bomb that would level Gotham and plunge it into an abyss. Commissioner Jim Gordon (voice of Hector Elizondo) tries to use the Bat-signal to contact Batman, but Eggman has egged it down.
Jim and Chief O'Hara go downtown to spring into action while the villains continue to run amok. Jim meets with Mayor McCaskill (voice of Mariah Carey) before she is airlifted to the central core. Joker and his villains are all gathered to watch the city be destroyed, but the Mayor reveals herself to be Batman in disguise. He proceeds to single-handedly beat down every villain before trying to catch The Joker. Batman latches onto Joker with his grappling hook but Joker reminds him that the bomb is still active. When Joker calls himself Batman's worst enemy, Batman rebuffs it by stating that Joker means nothing to him, and that nobody does. Joker looks heartbroken as Batman rushes to stop the bomb.
He succeeds, and the city cheers Batman on. Batman returns to his home on his own island. He spends his free time alone in the Batcave, eating leftover lobster thermidor and cackling maniacally during "Jerry Maguire". Batman later stares at a portrait of himself as a child with his parents on the night they died. He starts addressing the portrait and says his parents would have been proud that he saved the city again.
He is then startled by Alfred (voice of Ralph Fiennes), so Batman accidentally dropkicks him into the piano. After apologizing, Alfred realizes that Batman is going through another one of his phases and is just sad at the prospect of having another family. Alfred then reminds Batman that there is a gala later that day for Jim Gordon's retirement, which Batman reluctantly goes to. On the way to the gala, Batman (now out of disguise as Bruce Wayne) watches a news report on how Superman (voice of Channing Tatum) sent General Zod into the Phantom Zone. Joker is watching the same report in his lair with Harley and sees certain famous villains beyond the realm of Gotham City are contained there.
Thus, Joker hatches his latest idea. At the gala, Bruce is approached by an orphan, Dick Grayson (voice of Michael Cera). He's a sweet kid who longs for another family. Dick asks Bruce if he would consider adopting him, just as Bruce's attention is caught by the new commissioner, Jim's daughter Barbara (Rosario Dawson). She gets up to talk to the citizens of Gotham about her latest idea: she wants the police force to team up with Batman because on his own, he hasn't done much to take care of the huge crime problem in the city. Bruce does not like the idea one bit, and moments later, the gala is interrupted by Joker and his villain team.
Bruce goes into Batman mode and Master-Builds himself a vehicle while Barbara attempts to confront Joker on her own terms. To everyone's surprise, Joker surrenders himself and all the villains (except Harley) to the police. With Gotham's worst all locked up, Barbara receives credit while Batman is left to go home in disbelief. Batman stalks Arkham Asylum for any suspicious activity.
He sees a van driven by Harley (now out of disguise as Harleen Quinzel) with the logo "Phantom's Own Laundry Service". He knows something suspicious is going on, but Barbara sees him and tells him to let the police worry about it. Back at Wayne Manor, Batman tries to access Joker's plans through the computer, but Alfred put a parental lock on the computer. He tells Batman that he should spend time with Dick, whom he had adopted over a week ago. Batman is baffled and refuses to do anything with the boy until Alfred purposely leads Dick into the Batcave. Dick is amazed to know that Batman is one of his new dads.
Meanwhile, Batman schemes to put Joker in the Phantom Zone, but he must steal the Phantom Zone Projector, which is located in Superman's Fortress of Solitude. When the computer determines that Batman is way too "jacked" to fit into the vents that would take him to the Projector's location, he gets the idea to have Dick join him so that he can fetch it. Dick goes through Batman's costumes for a cool outfit to wear, and he settles on Batman's "Reggae Man" outfit and names himself Robin. The Dynamic Duo arrive at the Fortress of Solitude. While Robin goes to find the Projector, Batman creates a diversion by knocking on Superman's door. To Batman's surprise, Superman and the rest of the Justice League - including Green Lantern (voice of Jonah Hill), Flash (voice of Adam Devine), Wonder Woman, Cyborg, Aquaman, Martian Manhunter, and the Wonder Twins - are celebrating an anniversary party without having invited Batman. A dejected Batman leaves when nobody is looking just as Robin has gotten through the complicated security system to retrieve the Projector. Batman almost admits that he's proud of Robin, but he's also too proud to admit it.
Batman and Robin head on down to Arkham to take on Joker. Barbara finds them and has them go through security. When Robin is caught trying to smuggle the Projector, the two beat up the guards and run to Joker's cell. Just as he expected, Batman confronts Joker and hits him with the Projector, sending him into the Phantom Zone. In the Phantom Zone, Joker is met by a sentient brick called Phyllis (voice of Ellie Kemper). After scanning Joker for badness, she has him meet some of the most notorious villains of all time, like Lord Voldemort (voice of Eddie Izzard), Sauron (voice of Jemaine Clement), King Kong (voice of Seth Green), The Kraken, Jaws, Agent Smith, Dracula, Medusa, The Wicked Witch of the West, the Gremlins, and the Daleks. He tells the villains that he has a plan to get them all out of there. Back in Arkham, Harley steals the Projector and uses it to bring back every last villain.
Joker unleashes them all on the city to cause mass mayhem. Sauron floods the streets with lava, Voldemort turns people into animals, and King Kong smashes through the city. Batman (who got himself and Robin locked up) asks Barbara to let him go so that he can go save the city. She agrees only on the condition that he allow her to join and help. Batman begrudgingly agrees, and he is now joined by Barbara, Robin, and Alfred (who somehow made it from Wayne Manor to Arkham on his own). The heroes take the Batwing across the city as they try to locate Joker. Sauron has his eye locked on Batman and has led Joker to Wayne Manor, where Joker finds Batman's stash of romantic comedies. The Gremlins start tearing into the Batwing, leading Batman to hop outside and leave the Batwing on autopilot with some rope tied to the controls.
Robin and Alfred join him in taking out the Gremlins. Robin falls off the Batwing, and Batman jumps to rescue him. Alfred falls off too and nearly plummets to his death, but Barbara takes control of the Batwing and saves him. Batman then comes up with a plan and has Barbara fly toward Sauron's eye, just as Kraken blasts a fireball at the Batwing. At the right moment, Barbara steers the Batwing away and causes Sauron to get blown to bits, meaning Joker no longer has an eye on Batman. The heroes make it to Wayne Island and applaud each other for their accomplishments. Robin takes a selfie with everyone as his new family, which then strikes a nerve with Batman.
The other three go into the Batwing for more gear, but Batman locks them in there and has the computer send them to the border of Gotham City and Bludhaven so that he can protect them and fight Joker on his own. Batman finds Joker inside his home, but Batman is surrounded by all the villains, completely outnumbered. Joker only wants to hear Batman say that he hates him and considers him his worst enemy, but Batman is stubborn and refuses to acknowledge it. Joker takes the Projector and sends Batman to the Phantom Zone. Batman meets Phyllis, who scans him and determines that while he's not bad enough to be considered a villain, he has done a lot of bad things to people that care about him. Batman realizes he has been trying to protect himself from getting hurt again. He makes a deal with Phyllis to bring back all the villains if she lets him go back to Gotham.
Batman's computer overrides his commands to protect him and sends Robin, Barbara, and Alfred back to the island to fight the villains. Batman is sent back as well, and he apologizes to his friends for deceiving them. He opts to get help not only from them, but from all of his enemies broken out of Arkham. He even gives Barbara her own suit, dubbing her "Batgirl". The team faces off against Joker's villains, with all of them being gradually sent back to the Phantom Zone. However, the bomb from earlier goes off and starts to break the city apart. Batman and his friends all form a chain link using their heads and feet to pull the city back together, along with the citizens of Gotham.
It's still not enough, so Batman is forced to ask for Joker's help. Batman admits to Joker that he truly is his greatest enemy and that they need each other. Joker is touched and helps Batman pull the city back together. With the city saved, Batman must fulfill his end of the bargain and return to the Phantom Zone.
He reveals himself as Bruce Wayne to Robin and finally accepts him as a son. They have a tearful hug goodbye as Batman ascends to the Phantom Zone. However, he gets blocked from going up. Phyllis appears and tells Batman that she has seen how he changed to help those that he cares about, and has decided he can stay with his friends. Batman and Joker then part ways as Joker heads off with the rest of the rogues. Batman decides to give them a 30-minute head start before he and his team go catch them. Batman and Robin are both now part of a new family. Batman hangs up the family selfie in his room.
As the credits begin, Robin asks Batman if he can play a song that he's written specifically for the credits. Batman and all his friends and enemies get together to perform the song..