The Duel on the Imperial Palace was a confrontation that took place on the Imperial Palace of Coruscant, formerly the Jedi Temple of the Jedi Order, in 5 ABY. It began with the Sith Lord Leia Organa facing her brother the Jedi Knight Luke Skywalker to prove her loyalty to the dark side of the Force, but ultimately, the Sith Lords Emperor Palpatine and Darth Vader joined the duel; the former to kill the twins and the latter to defend them and gave them a chance to escape. The duel ultimately finished when the Jedi Master Yoda crashed the Justice Star against the Imperial Palace, effectively ending with Palpatine and leading to the definitive fragmentation of the Galactic Empire.
In 0 BBY, after the astromech droid R2-D2 succeeded in acquiring the plans of the Galactic Empire's Death Star superweapon and then gave it to the Alliance to Restore the Republic thanks to the efforts of the Force-sensitive Luke Skywalker and the smugglers Han Solo and Chewbacca, who also helped to rescue Princess Leia Organa, Rebel leader, from the Death Star. Now with the plans, the Rebels decided to destroy the Death Star once and for all and avoid it destroying another planet following the Destruction of Alderaan. The Rebels boarded their respective starfighter and flew to the Death Star to participate in what became the Battle of Yavin.
The battle didn't end with the victory for the Rebels. Though Han Solo and his Wookiee Chewbacca opted to join the battle later, Skywalker failed to destroy the station's main reactor with his proton torpedoes, albeit he prevented the complete destruction of Yavin 4. Unable to accept his failure, Skywalker jumped into hyperspace with his X-wing attached to the tail of the Millennium Falcon, Solo's freighter, as Solo knew that there was no chance to win anymore. On the other hand, Leia and the other Rebels were taken in custody when they attempted to escape from the Yavin system. While the Rebels were imprisoned at the Death Star, Leia was put under house arrest at Emperor Palpatine's Imperial Palace, which was the Jedi Temple of the Jedi Order in the past, with the intentions to seduce her into the dark side of the Force.
Meanwhile, Skywalker, as instructed by his late Jedi Master Obi-Wan Kenobi, went to Dagobah along Solo and Chewie to meet Master Yoda, who trained Luke during five years while Solo and Chewie returned to their smuggling life whilst Darth Vader trained Leia into the dark side of the Force. However, during his training, Luke had a Force vision about him killing Leia, though he didn't knew. By 5 ABY, five years following the failed Battle of Yavin, Skywalker was now a Jedi Knight ready to face the Empire, while Leia was now a Sith Lord, convincing the dying Emperor Palpatine to reinstate the Imperial Senate.
After leaving Dagobah with the Rebels, Yoda was left at the Justice Star to confront Admiral Tarkin with a Force mind trick while Solo and Skywalker went to the Imperial Palace. After slaining several Emperor's Royal Guards, they were guided by a reprogrammed C-3PO the Emperor's throne room, where he ordered Leia to duel his brother just as he revealed the truth of their parentage. Though Luke initially refused to duel his own sister, C-3PO subdued Solo and Palpatine threatened to order C-3PO to execute Solo if Skywalker didn't decided to fight his Sith apprentice.
Immediately, Leia started the duel against her brother by activating her lightsaber. During the fight, however, an Imperial officer contacted Palpatine to warn him that the Justice Star was destroying multiple ships of their fleet, including many Star Destroyers, with its superlaser, apparently being commanded to do so by Admiral Tarkin, who was being manipulated by Yoda to destroy that ships in order to weaken the Empire.
Upon hearing this news, Palpatine ordered Darth Vader to contact Admiral Tarkin, but Vader was shocked by realizing that he had a daughter, muttering Leia's name. While the two Skywalker fought against each other, Luke persuaded his sister to listen to her feelings, causing Leia to conclude that Skywalker wasn't lying, prompting her to end the duel. Palpatine, however, said her that her feelings were betraying her and they had too betrayed himself, trying to order her to continue with the fight, but Luke stated that the fight was over and that they were Skywalkers leading Palpatine to Force lightning the two Skywalkers by saying to them that their lack of strength to be the future had lead the dark side to decide that they would not see the future.
Fortunately for the Skywalker twins, Vader jumped off the platform where he was standing and knocked off the Emperor, causing him to cease electrocuting his children with Force lightning. Realizing that he was still a Jedi after all, Anakin ordered his children to flee from the Imperial Palace as he restrained the Emperor. Shortly after subduing C-3PO to not have Han killed, the three friends made their way by letting Luke and Leia to slain several stormtroopers. Anakin was quickly defeated by the Emperor, who asked him if his sacrifice would change anything. Nevertheless, Yoda contacted Palpatine to reveal to him that he thought that though maybe his "pitiful powers" weren't enough against the dark side, the dark side hadn't protected the Imperial fleet even though the Imperial troops had disabled the Justice Star's weapons systems. To Palpatine's horror, the last thing he ever saw by his palace's window was the Justice Star, which crashed against the Imperial Palace, effectively killing Sidious, Yoda, R2, Tarkin and Anakin in the process.
Ultimately, Anakin's and Yoda's sacrifices were not in vain. The death of Palpatine lead to the definitive fragmentation of the Galactic Empire once and for all. In addition that both Anakin and Leia were brought back to the light side of the Force, C-3PO's systems returned to normal as all of the Empire's awful programs were definitely purged. Some years later, at Naboo, a ceremony was held for Leia, now the Supreme Chancellor of the New Republic. During the ceremony, Luke was able to see the Force ghosts of Obi-Wan, Yoda and his father Anakin, much to his joy, now that with Leia reformed, they will all bring peace and justice to the galaxy forever.