Battle of the Foundry The Battle of the Foundry was an early battle of the Galactic War between the Galactic Republic and the Sith Empire . Darth Malgus , commander of the Imperial Expeditionary Fleet , assembled a strike team and revealed to them the existence of an ancient space station known as the Foundry , a relic of an ancient civilization , and of a powerful Jedi Master who commanded it . Prelude . The Jedi Master had been imprisoned by the Sith Emperor at a secret prison base in the Maelstrom for three hundred years , kept in an unaging stasis by ancient technology and Sith sorcery . A Republic strike team sent by the Jedi Admiral Oteg managed to locate the prison , kill its warden , Grand Moff Rycus Kilran , and free the Jedi from the Maelstrom prison . After briefly returning to the Republic , the Jedi Master set out for the Foundry - a secret he had managed to keep from the Emperor during their long psychic bond - and began to use it in the service of the Republic . Darth Malgus revealed to his chosen strike team that the escape had in fact been intended , so that the Jedi could lead the Empire to the Foundry and use it as part of the coming war with the Republic . In order to claim the Foundry , Malgus and Moff Phennir , commanding the Harrower - class dreadnought " White Nova " , planned to hijack a Republic transport ship bound for the Foundry , and use it to infiltrate the Foundry while Phennir led the fleet to engage the Foundry ' s defenses . The strike team carried out this first mission , leading a sneak attack against the Republic transport ship " Dorin ' s Sky " and taking control of the bridge , slaying the elite Storm Squadron and executing Captain Yelto and her crew . With the " Dorin ' s Sky " in their hands , the strike team could now lay in a course for the Foundry . Their task was two - fold : Secure the Foundry for Imperial occupation troops , and eliminate the Jedi Master . The battle . Arriving six hours off schedule as a result of the hijacking , the " Dorin ' s Sky " docked with the Foundry without incident . Rushing from the airlock , they engaged the Foundry ' s defense force of Jedi , Republic soldiers and battle droids . As they made their way through the station , they discovered that it appeared to be a massive droid factory , producing custom - built " extermination droid s " for the Foundry ' s master . As they made their way through the outer defenses , they were contacted by the Jedi Master , who hoped to convince them to give up their quest and surrender . Meanwhile the Imperial Expeditionary Fleet engaged the Republic fleet over the Foundry . The Republic fleet quickly surrounded the foundry preventing the Imperial ships from retreating . The Imperial ships then began suffering heavy losses . Despite this they continued fighting , needing to hold off the Republic forces as the strike team made their way through the Foundry . Within the droid factory ' s main generator , they confronted the leader of the droid armies , an assassin droid who identified himself as HK - 47 , " the master ' s most faithful ally " . HK - 47 revealed that the extermination droids had been equipped with bioscanners capable of detecting Sith genetic material and killing any who had Sith ancestry , which would account for 97 . 8 % of the population of the Empire . Activating his assassination protocols and summoning extermination units to attack the strike team , HK - 47 would eventually sustain serious damage and shut down . Crossing over the asteroid ' s shielded surface and entering the inner sanctum of the station , the strike team came face to face with their quarry . The Jedi Master revealed himself to be Revan , a Jedi Knight from three centuries earlier who was corrupted by the Sith Emperor and led a Sith invasion of the Republic after the Mandalorian Wars . Redeemed by the Jedi , Revan returned to the Empire and confronted the Emperor on Dromund Kaas , but was defeated due to betrayal from within and imprisoned for the next three hundred years . During his long imprisonment , Revan and the Emperor influenced one another ' s minds ; the Emperor seeking to make him Darth Revan again , and Revan convincing the Emperor that peace was in his best interest . After being freed from the Maelstrom , Revan returned to the Foundry to oversee what he believed would be the final downfall of the Sith and their Empire . He pleaded with the strike team to see reason and abandon the Emperor , but they refused . The strike team also tried to convince Revan the error in his way , but Revan believed that he needed to destroy the empire , even at the cost of its entire population . Revan drew his lightsaber , and the duel began . Revan proved a formidable opponent , skilled with his blade and with the powers of the Force , raining asteroids harvested by the Foundry and unleashing powerful bursts of Force lightning . But in the end , it was not enough to defeat the Empire ' s top agents , and Revan was defeated . Remarking that now he knew what his old friend Malak had thought when he defeated him three centuries earlier , Revan vanished in a burst of Force energy . At last Imperial reinforcements arrived and mopped up the last of the Republic ships . The space battle was over by the time Revan was defeated . Aftermath . The duel ended with Revan eliminated as a threat to the Empire , and the four agents were praised and given high prestige and honor . They were later debriefed on Revan and his role and were considered heroes for saving the Empire and capturing the Foundry . However , their work was nearly squandered when Malgus declared his " New Empire " and used the Foundry as part of his plans ; Malgus ' forces defending his mobile space station included rewired extermination droids , commanded by the rebuilt and reprogrammed HK - 47 . Moff Phennir , one of the members of the war council to counter the " New Empire " during the Battle of Ilum , was outraged at the betrayal and of his unwitting part in it . Revan was believed to have been killed in the battle , but re - emerged on Rakata Prime in 3638 BBY at the head of the Order of Revan , once a fringe cult in the Empire , now a galaxy - spanning force .