Set after the events of the show's third season finale "Magical Mystery Cure", in Equestria, the newly crowned Princess Twilight Sparkle visits the Crystal Empire with her Ponyville friends for a royal summit with Princess Celestia, Luna, and Cadance. That night, Twilight's crown and Element of Magic is stolen by the unicorn Sunset Shimmer, a former student of Celestia. After a chase through the castle, Sunset drops the crown through a magic mirror and follows after it. The princesses inform the ponies that the mirror leads to a different world, and task Twilight with retrieving her crown on the other side before the portal closes again for thirty moons, or else the Elements of Harmony borne by her friends will no longer protect Equestria. Despite Celestia's insistence that Twilight must travel alone, Twilight's dragon assistant Spike anxiously jumps in after her as she enters the mirror.
In the other world, Twilight and Spike are transformed into a teenage human girl and dog, respectively. They also meet Princess Celestia's old acquaintance Doctor Aaron and Cynder. While struggling to adjust to her new body, Twilight and the TARDIS team investigate the nearby Canterlot High School where they encounter several human students and faculty members resembling ponies in Equestria, including Twilight's friends Applejack, Fluttershy, Pinkie Pie, Rarity, and Rainbow Dash. Twilight, Spike, Doctor Aaron and his crew befriend the five girls, helping to bridge the animosity that Sunset had created between them in the years prior to Twilight and the TARDIS Team's arrival. Twilight discovers that Fluttershy found the crown and gave it to Celestia, the school principal, who mistakes it for a prop meant for the elected Princess of the upcoming Fall Formal. Twilight decides to run for Fall Formal Princess against Sunset to retrieve the crown. Sunset who is being aided and abetted by Jestro, The Book of Monsters, and the Lava Monster Army try sabotaging Twilight's campaign first by uploading a humiliating online video of Twilight behaving like a pony, and later framing her for wrecking the formal decorations in the school gymnasium. However, Twilight's new friends, including Sunset's ex-boyfriend Flash Sentry, help counter these ploys and improve Twilight's popularity among the students.
At the formal, Twilight wins the election and the crown, but Sunset steals it after threatening to destroy the portal to Equestria. Upon donning the crown, Sunset transforms into a demonic creature and uses her newfound powers to brainwash much of the student body into becoming her army with which to invade Equestria and injures Doctor Aaron. When Sunset attacks Twilight, her friends race to save her, evoking the crown's magic that protects them and temporarily gives them pony-like attributes. The magic of their friendship reverts Sunset to her human form and breaks her spell on the other students. Sunset becomes repentant, and Twilight asks her friends to look after Sunset in her TARDIS team's absence. Twilight spends time celebrating with her friends at the formal before she and Spike take the crown through the portal, which closes behind them. Twilight and Spike return to Equestria, transforming back to their original forms on arrival and reuniting with their Ponyville friends.