In the human world, the students of Canterlot High School are preparing for an upcoming musical showcase, with Twilight Sparkle's human friends to perform in their own band, the Rainbooms, at the event; they find that they assume half-pony forms whenever they play, caused by the Equestrian magic left over from Twilight's crown. Meanwhile, former school bully Sunset Shimmer is ostracized by the rest of the student body despite her attempts to redeem herself, though Twilight's friends still value their newfound friendship with Sunset. Sunset volunteers to show three new students—Adagio Dazzle, Aria Blaze, and Sonata Dusk—around the school. The trio, calling themselves the Dazzlings, perplex Sunset and the Rainbooms when they sing a song that creates dissent amongst the rest of the student body and convinces them to turn the showcase into a battle of the bands. Finding that the Dazzlings have also put Principal Celestia and Vice Principal Luna under their spell, Sunset writes to Twilight for help through a magic book given to her by Princess Celestia.
Twilight receives Sunset's message while settling into her new castle in Equestria. She discovers that the Dazzlings are sirens exiled from Equestria who feed on negative emotions to control others through their singing. Using the book's magic to create a means of activating the portal between worlds, Twilight returns to the human world alongside Spike and reunites with her human friends. She suggests that they use the power of friendship to counter the Dazzlings' spell, but they are unable to evoke their magic. Twilight determines that they must perform a song together as to cast their counterspell; Rainbow Dash puts Twilight as the band's lead singer as she begins to work out lyrics for the counterspell. The Dazzlings are alerted to the magic protecting the Rainbooms and set the rest of the student body against the band, creating strife within the group and increasing their vulnerability to the trio's spell.
At the competition, the Rainbooms best each opposing band, giving Twilight more time to work out the spell. During the semifinal round against Trixie Lulamoon's band, Rainbow Dash breaks out into an egotistical song that nearly triggers her half-pony transformation. Sunset stops her, knowing that this would expose their plan to the Dazzlings, but this is seen as a selfish act by the student body, furthering their dislike of Sunset. The Dazzlings guile Trixie into trapping the Rainbooms beneath the stage to prevent them from participating in the final round, during which the Dazzlings absorb their magic as Twilight's friends argue with each other. Twilight and Sunset realize that the hostility in their group is preventing Twilight's spell from working, and convince the others to work together. The band is rescued by Spike and DJ Pon-3, the latter being protected from the Dazzlings' singing by her headphones. Performing on a makeshift stage provided by DJ Pon-3, the Rainbooms transform and fend off the Dazzlings' siren forms in a magical battle. Backed by Sunset, who also transforms, the full band is able to break the Dazzlings' spell and destroy the gems that empower the trio, rendering them tone deaf. The Dazzlings run off in defeat while the rest of the school celebrates. Twilight and Spike return to Equestria with the ability to return at any time, keeping in touch with Sunset via her magic book.
A montage that plays during the closing credits shows Sunset being accepted by the student body and performing as the Rainbooms' new lead singer and guitarist. In a post-credits scene, the human world's version of Twilight Sparkle is shown investigating the strange activity around Canterlot High.