"Battle for the Sunstar" is the thirty-third episode of the Star Wars: Ewoks animated television series, and the twentieth episode in season two. Written by Paul Dini and directed by Raymond Jafelice, the episode originally aired on ABC on December 6, 1986. The episode re-aired on January 10, 1987, and that marked the official end of the series.
Doctor Raygar, an evil scientist to EmperorPalpatine, has designs on ruling the Galactic Empire and travels to the Forest Moon of Endor to obtain the powerful Sunstar from the Ewoks' Bright Tree Village. He is attacked by the shaman Logray, who uses the Sunstar against him but Raygar's Imperial Reconnaissance Droids soon overwhelm the village and the evil doctor retaliates by swiftly stealing the Sunstar, before returning to Admiral Kazz's Star Destroyer in orbit.
Back in his lab, Raygar begins studying the Sunstar and comes to the realization that by harnessing its power, he could remove Palpatine and install himself as the Galactic Emperor. But when creating a dangerous cannon with the Sunstar's powers, Raygar discovers that Wicket W. Warrick, PrincessKneesaa, Latara and Teebo have come aboard the Kazz's Star Destroyer with the help of a pilot droid named PD-28. Raygar plans to test his weapon on the captive Ewoks- Latara and Teebo, but is thwarted by Wicket. Inadvertently, Raygar fires upon the Emperor's approaching shuttle instead. Palpatine survives, and Admiral Kazz subsequently arrests Raygar, charged with high treason. The Emperor then oversees the doctor's punishment personally. With PD-28, the Ewoks return safely to the Forest Moon of Endor, where Wicket, Kneesaa, Latara and Teebo say good-bye to the pilot droid as he embarks on a search for his old master.
This episode involves the Empire apparently discovering the Endor moon, leading to their occupation of the planet, as seen in Star Wars Episode VI: Return of the Jedi.