The concluding engagement of the Jedi Civil War is recognized as the Battle of Rakata Prime. This conflict unfolded in the vicinity of the primary star within the Lehon system. The navies of both the Galactic Republic and Darth Malak's Sith Empire clashed, with each side receiving support from their respective Force-users. Amidst intense combat between capital ships and starfighters around the colossal space station and manufacturing facility known as the Star Forge, the Jedi, under the command of the redeemed Revan, successfully breached the station's defenses. Their objective was to confront Malak, vanquish the Sith, and bring an end to the devastating war.
The events leading up to the battle began when the crew of the Ebon Hawk acquired the fifth and last Star Map, accurately determining the covert location of the Star Forge. Given that this immense factory complex, fueled by the dark side of the Force and the energy of the star it circled, acted as the core of the Sith's military capabilities, Carth Onasi communicated the coordinates to the Republic fleet, with the intention of orchestrating a swift assault to neutralize the massive space station. Soon after, his ship, the Ebon Hawk, inadvertently flew through a Disruptor field, resulting in the destruction of several key systems within the heavily-modified freighter. This forced him to execute an emergency landing along the coastline of one of Lehon's numerous islands.
Subsequently, Revan and his companions embarked on a mission to recover the necessary components to repair their ship and identify the origin of the disruptor field before the Republic fleet's arrival. During their journey, they encountered remnants of the ancient Rakatan Infinite Empire, specifically engaging with the formidable warriors of the Black Rakata tribe. Shortly thereafter, Revan encountered the Elders, who revealed the truth regarding the Star Forge's origins and purpose. Aided by the Elders, Revan, accompanied by Jolee Bindo and Juhani, infiltrated the Temple of the Ancients, eliminating the numerous Dark Jedi and Sith troopers that occupied its interior. Following a brief confrontation with Bastila Shan, who had been captured by Malak and succumbed to the dark side, the disruptor field was deactivated just as Republic warships emerged from hyperspace and initiated an attack on the Sith fleet defending the Star Forge. In preparation for the inevitable confrontation with Malak and the Sith, Revan and his crew repaired their ship and ascended to join the ongoing battle.

As they approached the unfolding battle, Carth contacted Admiral Forn Dodonna, who was commanding the assault fleet. He informed her that Bastila had fallen to the dark side and was utilizing her battle meditation abilities against the Republic from within the Star Forge. With the battle shifting against the Republic fleet, Jedi Master Vandar Tokare, serving as an advisor aboard Dodonna's flagship, dispatched a team of Jedi Knights to escort the crew of the Ebon Hawk. Together, they penetrated the Forge's outer defenses and boarded the massive space station, aiming to disrupt Bastila's use of her powers and, in Revan's case, to confront his former friend and apprentice. While a few Jedi remained at the docking bay to secure an exit for the strike team, Revan, his companions, and other Knights attempted to infiltrate the station's interior.
Upon realizing that the station had been boarded, Malak deployed a contingent of the Forge's battle droids to thwart the impending threat. However, Revan and his companions proved capable of overcoming this obstacle and advanced deeper into the station's inner workings. As a temporary measure, Malak ordered all available Sith troopers, Dark Jedi, and their apprentices to engage in combat. Although he recognized that they would not defeat his former master, the Dark Lord of the Sith anticipated that they would sufficiently delay him, allowing his new apprentice, Bastila, to prepare to fight and potentially eliminate the one she loved, thereby demonstrating her loyalty and worth. After defeating a trio of Dark Jedi guarding the entrance to the Star Forge's command center, Revan became separated from his companions and was compelled to confront Bastila alone. Despite drawing upon the power of the Star Forge, the former Jedi was unable to defeat Revan and pleaded for him to end her life. However, Revan refused and urged Bastila to recognize the light within herself by drawing upon both the Force bond and the bond of love they shared. Bastila heeded his words, confessing her own love and redirecting her battle meditation to aid the Republic forces, while Revan proceeded to confront Malak.
Revan faced Malak at the station's highest point. Malak, having struck down two captured Jedi, activated several ancient droid-producing machines. After sealing the room, he retreated further into the factory complex. Revan eventually navigated through the onslaught of combat droids, deactivated the factory, and advanced, ultimately defeating Malak in a spectacular lightsaber duel. During the duel, the Dark Lord attempted to siphon the remaining Force-energy from Jedi killed during his attack on the Jedi Enclave on Dantooine. However, Revan utilized his own Force powers to prevent further siphoning. After defeating his former apprentice, he, Bastila, Carth, and the others boarded the Ebon Hawk and escaped the station's destruction.
While the Jedi infiltrated the station, Admiral Dodonna strived to hold off the Sith forces, despite the unfavorable odds. With battle meditation hindering the Republic's efforts, she struggled to find a means of attacking the station itself. As the battle progressed, the Star Forge continued to produce Sith fighters, Sith freighters, and even capital ships, deploying them directly into battle. Despite the increasing challenges, Dodonna successfully maintained her fleet's presence at the edge of the engagement zone.

When Revan redeemed Shan, the tide of the battle began to turn, initially subtly, until Dodonna observed a sudden breach in the Sith formation while monitoring the tactical situation. Reacting swiftly, she deployed two of her elite starfighter units. Green Squadron was ordered to exploit the opening, followed promptly by Red Squadron, which rapidly expanded the breach into a salient, enabling the main fleet to attack. As the Hammerheads and blockade runners surged through the shattered lines, numerous Sith capital ships were destroyed. As the decisive duel within the Star Forge's upper levels concluded, Dodonna's fleet converged on the massive station, bombarding it with turbolasers while intense dogfights filled the skies with explosions. Overwhelmed by the combined firepower, the station's orbital stabilizers were soon destroyed. Dodonna then ordered her ships to retreat as rapidly as possible before the Forge's final destruction.
As the Star Forge plunged into the Rakatan sun and detonated in a colossal explosion, scattering glowing debris across millions of kilometers of space, the Ebon Hawk narrowly escaped, staying just ahead of the conflagration's wavefront. With the Sith fleet decimated, the vast orbital factory destroyed, and the Dark Lord defeated, the Republic forces and surviving Jedi Knights gathered on Lehon at the base of the Temple of the Ancients to celebrate their triumph.

Dodonna bestowed the Cross of Glory upon Revan, Bastila Shan, Jolee Bindo, Zaalbar, Mission Vao, Canderous Ordo, Juhani, and Carth Onasi in recognition of their contributions to the battle. With both Bastila and Revan returned to the Republic's side and the Sith Empire's primary factory eliminated, the Sith forces were quickly dispersed by the Republic. The survivors retreated into hiding, aligning themselves with Darth Sion, Darth Nihilus, and Darth Traya in the years that followed. The Sith Academy on Korriban became a central point for the internal conflicts that erupted among the remnants of the Sith. Even under Darth Traya, they never regained the strength to overtly challenge the Republic and the Jedi as they had under Revan and Malak.
Following the battle, the wreckage of the ships and the Star Forge formed a ring around the planet. The Republic designated the site a historical zone and restricted travel to it, aiming to prevent Sith adepts from accessing the Force-rich surface of the world. However, during the New Sith Wars three millennia later, these travel restrictions appeared to be loosely enforced, if at all, as Darth Bane was able to travel there unhindered to locate Darth Revan's holocron.
In the years after the fall of the Star Forge, the eight heroes of the battle were commemorated by a series of holostatues depicting their likenesses in Axial Park on Corellia. During the Battle of Corellia in the Galactic War three centuries later, these holostatues, initially disabled by Sith forces, were reactivated by Republic heroes to bolster the morale of Republic soldiers fighting to liberate Corellia.

In the novel Darth Bane: Path of Destruction, authored by Drew Karpyshyn, Revan was described as a Jedi Master at the time of the duel. However, in Knights of the Old Republic, he is portrayed as a Padawan. An image depicting Revan and Malak's final duel was included in The Jedi Civil War, the eighth installment of the Galactic Timeline, an online video series created to expand upon the background of the video game Star Wars: The Old Republic. In this image, Bastila Shan is also shown confronting Malak. However, in Star Wars: Knights of the Old Republic, she was utilizing her battle meditation to support the Republic fleet, leaving Revan to confront Malak alone. An easter egg in the ending of Star Wars: Knights of the Old Republic allows the player to transform Malak into a green-skinned Twi'lek dancer and bypass the final battle.
The Duel on the Star Forge initially appeared in the 2003 video game Star Wars: Knights of the Old Republic, developed by BioWare. The light-sided ending, in which Revan defeats Malak and destroys the Star Forge, has been confirmed as the canonical ending by The New Essential Chronology, Jedi vs. Sith: The Essential Guide to the Force, and the Knights of the Old Republic Campaign Guide.
In the alternative dark side ending of the game, the resurrected Darth Revan reassumed the title of Dark Lord of the Sith. Taking Bastila as his Sith apprentice, Darth Revan relentlessly battled his way through the Star Forge to defeat his former protégé, Darth Malak. Upon reaching the Star Forge command center, Bastila employed her battle meditation to hinder the Republic fleet, while Revan advanced, evading the Star Forge's defenses and fighting his way to the factory level. The Sith Lord then mercilessly struck down his treacherous former apprentice in a lightsaber duel. Under Bastila's battle meditation, the Sith fleet annihilated the Republic fleet, resulting in the deaths of both Master Vandar and Admiral Dodonna. Following the battle, Darth Revan was celebrated by the Sith and re-elected as the Dark Lord of the Sith.
With a significant portion of the Republic fleet destroyed, Darth Revan traveled to Korriban to unite the Sith in a final effort to crush the Republic. However, abruptly and without explanation, he ceased his campaign and departed known space. Without Revan's strong dark side mastery and leadership, the Star Forge deteriorated due to misuse by lesser Sith Lords. Bastila refused to follow the remaining Sith Lords, stating, "whoever survives this Sith civil war will not be one I wish to follow. There is only Revan," and left Korriban in search of Revan, shortly before the Sith Empire and the Korriban academy fell. The resulting power vacuum led to a civil war and the collapse of the majority of the empire, paving the way for Darth Traya and her apprentices, Darth Nihilus and Darth Sion, known as the Sith Triumvirate, to seize control of the remnants.