Knights of the Old Republic has two distinct endings, shaped by the path you take through the story: the light side or the dark side.
If you finish on the light side, you defeat Darth Malak. A short cinematic then shows you and Bastila, along with the rest of your party, escaping aboard the Ebon Hawk. As you fly away, the Star Forge erupts in explosions behind you, marking the end of the Sith threat.
Choose the dark side and, after defeating Malak, you're shown standing on a cliff overlooking the Star Forge while soldiers and Dark Jedi chant in your honour as the new Sith ruler. Bastila declares that Revan has returned to lead the Sith, and the scene closes with a Republic starship being destroyed in the distance.
In short, your moral choices decide whether you're remembered as a saviour of the Republic or the feared master of the Sith.